mirror of
https://github.com/g-truc/glm.git
synced 2025-04-10 07:18:54 +00:00
Quaternion vector rotation error. #209
This commit is contained in:
parent
ea45a7b966
commit
c506b43d49
2 changed files with 15 additions and 4 deletions
|
@ -302,11 +302,11 @@ namespace detail
|
|||
detail::tvec3<T, P> const & v
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> u(q.x, q.y, q.z);
|
||||
detail::tvec3<T, P> uv(glm::cross(u, v) * q.w);
|
||||
detail::tvec3<T, P> uuv(glm::cross(u, uv));
|
||||
detail::tvec3<T, P> const QuatVector(q.x, q.y, q.z);
|
||||
detail::tvec3<T, P> const uv(glm::cross(QuatVector, v));
|
||||
detail::tvec3<T, P> const uuv(glm::cross(QuatVector, uv));
|
||||
|
||||
return v + (uv + uuv) * static_cast<float>(2);
|
||||
return v + ((uv * q.w) + uuv) * static_cast<T>(2);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
|
|
|
@ -247,6 +247,16 @@ int test_quat_type()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int test_quat_mul_vec()
|
||||
{
|
||||
glm::quat q = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
|
||||
glm::vec3 v(1, 0, 0);
|
||||
glm::vec3 u(q * v);
|
||||
glm::vec3 w(u * q);
|
||||
|
||||
return glm::all(glm::epsilonEqual(v, w, 0.01f));
|
||||
}
|
||||
|
||||
int test_quat_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
@ -269,6 +279,7 @@ int main()
|
|||
int Error(0);
|
||||
|
||||
Error += test_quat_ctr();
|
||||
Error += test_quat_mul_vec();
|
||||
Error += test_quat_two_axis_ctr();
|
||||
Error += test_quat_mul();
|
||||
Error += test_quat_precision();
|
||||
|
|
Loading…
Add table
Reference in a new issue