mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 08:54:35 +00:00
Merge pull request #682 from CaptainCarrot/Quaternion-Look-At
quatLookAt: removed internal normalization of input direction #682
This commit is contained in:
commit
5606dd1aac
@ -185,7 +185,7 @@ namespace glm
|
||||
|
||||
/// Build a look at quaternion based on the default handedness.
|
||||
///
|
||||
/// @param direction Desired direction of the camera.
|
||||
/// @param direction Desired forward direction. Needs to be normalized.
|
||||
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> quatLookAt(
|
||||
@ -194,7 +194,7 @@ namespace glm
|
||||
|
||||
/// Build a right-handed look at quaternion.
|
||||
///
|
||||
/// @param direction Desired direction of the camera.
|
||||
/// @param direction Desired forward direction onto which the -z-axis gets mapped. Needs to be normalized.
|
||||
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> quatLookAtRH(
|
||||
@ -203,7 +203,7 @@ namespace glm
|
||||
|
||||
/// Build a left-handed look at quaternion.
|
||||
///
|
||||
/// @param direction Desired direction onto which the +z-axis gets mapped
|
||||
/// @param direction Desired forward direction onto which the +z-axis gets mapped. Needs to be normalized.
|
||||
/// @param up Up vector, how the camera is oriented. Typically (0, 1, 0).
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL tquat<T, Q> quatLookAtLH(
|
||||
|
@ -230,7 +230,7 @@ namespace glm
|
||||
{
|
||||
mat<3, 3, T, Q> Result;
|
||||
|
||||
Result[2] = -normalize(direction);
|
||||
Result[2] = -direction;
|
||||
Result[0] = normalize(cross(up, Result[2]));
|
||||
Result[1] = cross(Result[2], Result[0]);
|
||||
|
||||
@ -242,7 +242,7 @@ namespace glm
|
||||
{
|
||||
mat<3, 3, T, Q> Result;
|
||||
|
||||
Result[2] = normalize(direction);
|
||||
Result[2] = direction;
|
||||
Result[0] = normalize(cross(up, Result[2]));
|
||||
Result[1] = cross(Result[2], Result[0]);
|
||||
|
||||
|
@ -99,9 +99,9 @@ int test_quat_lookAt()
|
||||
|
||||
glm::vec3 eye(0.0f);
|
||||
glm::vec3 center(1.1f, -2.0f, 3.1416f);
|
||||
glm::vec3 up = glm::vec3(-0.17f, 7.23f, -1.744f);
|
||||
glm::vec3 up(-0.17f, 7.23f, -1.744f);
|
||||
|
||||
glm::quat test_quat = glm::quatLookAt(center - eye, up);
|
||||
glm::quat test_quat = glm::quatLookAt(glm::normalize(center - eye), up);
|
||||
glm::quat test_mat = glm::conjugate(glm::quat_cast(glm::lookAt(eye, center, up)));
|
||||
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quat) - 1.0f) > glm::epsilon<float>());
|
||||
|
Loading…
Reference in New Issue
Block a user