Hi all,
I’m trying to rotate a box using the Myo quaternions, but I don’t really get the logic. Can someone help me with these rotations, actually I don’t want to translate to Euler, just to use the quaternion from the Myo sdk correctly.
Thanks
Hi,
a brief examination of Myo’s source files shows that quaternion components are stored as x, y, z, w. This is the same for Cinder’s implementation, provided by the GLM library. So you should be able to simply cast a Myo quaternion to a GLM quaternion, provided you use the same precision (float or double).
glm::quat q = reinterpret_cast<glm::quat>( myoQuaternion );
To use the quaternion, simply convert it to a 4x4 matrix. GLM has the toMat4()
function for that:
gl::pushModelMatrix();
gl::rotate( glm::toMat4( q ) );
...
// draw stuff
...
gl::popModelMatrix();
-Paul
Hi,
There is a gl::rotate
wrapper that takes a quat
as a param already in cinder.