Wrong Calculation for Vec3 times Quat
wumo opened this issue · 1 comments
wumo commented
glm
calculates vec3 * quat
as :
https://github.com/g-truc/glm/blob/23e0701c0483283440d4d1bcd17eb7070fa8eb75/glm/detail/type_quat.inl#L352-L356
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> operator*(vec<3, T, Q> const& v, qua<T, Q> const& q)
{
return glm::inverse(q) * v;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> inverse(qua<T, Q> const& q)
{
return conjugate(q) / dot(q, q);
}
That is glm::inverse(q) * v;
which can be expanded as conjugate(q) / dot(q, q) * v;
However Vec3 * Quat
is implemented in:
glm/src/main/kotlin/glm_/quat/quat_operators.kt
Lines 61 to 77 in 5b0f346
Where line 62 val dot = dot(a, a)
should be val dot = dot(b, b)
which calculates the dot product of a quaternion and then is used to calculate the inverse of the quaternion.
elect86 commented
nice catch, thanks