[osg-users] different result rotating Vec3d for Quat or Matrixd

Gianni Ambrosio g.ambrosio+osg at gmail.com
Tue Jan 24 02:25:14 PST 2017


Hi,
may be this is a newbie question but I would like to understand the reason of this behaviour.

I have to calculate the coordinate of a 3D point wrt a different coordinate reference. The new coordinate reference is simply rotated wrt the first one. I tried two different implementations with different results.

osg::Vec3d eyeOffset(0.0, 0.0, 300.0);
osg::Quat rotation(osg::DegreesToRadians(0.0), osg::Z_AXIS, osg::DegreesToRadians(0.0),  osg::Y_AXIS, osg::DegreesToRadians(45.0), osg::X_AXIS);
osg::Vec3d localEyeOffset = rotation * eyeOffset;
osg::Matrixd rotationMatrix(rotation);
osg::Vec3d localEyeOffset2 = rotationMatrix * eyeOffset;

I expected to have the same result for localEyeOffset and localEyeOffset2, while this is what I get:
localEyeOffset is (0.0, -212.132, 212.132)
localEyeOffset2 is (0.0, 212.132, 212.132)

Can you explain me why?

Regards,
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70034#70034








More information about the osg-users mailing list