glm & quaternions

Hi,

I try to use quaternions provided by glm but I have somes problems… I do that:

m_WorldPose.Orientation = poseParent->Orientation * m_Orientation;

note : they are all glm::quat
I included glm/glm.hpp and glm/gtc/quaternion.hpp

I try to compile and I get that:

error C2679: binary ‘=’ : no operator found which takes a right-hand operand of type ‘glm::detail::thalf’ (or there is no acceptable conversion)
1> c:\users\charlie\documents\visual studio 2008\projects\in55\3d_engine\glm-0.8.4.4\glm\gtc\quaternion.hpp(58): could be ‘glm::detail::tquat<valType> &glm::detail::tquat<valType>::operator =(const glm::detail::tquat<valType> &)’
1> with
1> [
1> valType=float
1> ]
1> while trying to match the argument list ‘(glm::gtc::quaternion::quat, glm::detail::thalf)’
I have no idea where it comes from, I hope it will be more clear fo you :slight_smile:

Thanks for your help!

++

Chances are that you expect to do a quaternion cross project.
For such operation you should use the function glm::cross:

m_WorldPose.Orientation = glm::cross(poseParent->Orientation, m_Orientation);

Quaternion has cross and dot product just like vectors.
GLM follows GLSL convention as much as possible so that quaternion uses the same rule than GLSL vectors and defines 2 function, cross and dot.

With GLSL you can transform your vector like this:

mat4 m;
vec4 v;
v = m * v;

GLM follows the same rule for matrices and vectors product and extend it to quaternion:

quat q;
vec4 v;
v = q * v;

Hope this help!

Ach… can’t believe I did it ^^’.
Thanks for taking time to answer that!

Other little problem: I can’t use operator== to compare vectors.

glm::vec3 test(1.0f, 2.0f, 3.0f);
glm::vec3 test2(4.0f, 5.0f, 6.0f);
if(test == test2)
      return true;

I get that:

Error 1 error C2678: binary ‘==’ : no operator found which takes a left-hand operand of type ‘glm::core::type::vector::vec3’ (or there is no acceptable conversion) c:…\src\corerectangle.cpp 186

I tried to include glm/virtrev/equal_operator.hpp but it didn’t change anything.

Thanks for your help ^^.

GLSL doesn’t define == for vectors so as GLM.

Plus == on vector doesn’t mean much.
You probably expect the behavior of the following code:

if(glm::all(glm::equal(test, test3)))
return true;

equal return a bvec3 (vector of 3 boolean components) and all return comparent the components of this bvec3 all together and return true is all the component are true.