Hi all,

I'm having fun learning about rotation about an arbitrary axis and it's not 
working as I expected it to at all.

I am using the code from the Trackball manipulator to construct a "local" 
origin at a point that is actually @ the edge of my earth sphere.

It goes like this:

osg::Vec3d Up(0,0,1);
osg::Vec3d focalPt(x,y,z);

osg::Vec3d x_axis = Up ^ focalPt; // up cross focal should give "x-axis"?
osg::Vec3d y_axis = x_axis ^ focalPt;// should be y-axis??
osg::Vec3d z_axis = x_axis ^ y_axis;

I can construct the "x-axis" w/o a prob and I can rotate about it - though it 
LOOKS LIKE A PITCH that I am actually performing and not a ROLL.
This behavior is very strange to me. :(

To actually perform the rotate, I do the following:

osg::Quat q(AngleOfRotation, x_axis);
osg::Matrixd mtxd = osg::Matrixd::rotate(q) * OriginalPositionMatrixd;

The mtxd computed is the correct rotation about the x-axis but, again, it 
appears to be a PITCH instead of a ROLL.

OriginalPositionMatrixd is computed as follows:
  osg::Vec3d ov3d = s_paxNode->getPosition();
  osg::Quat  q    = s_paxNode->getAttitude();
  osg::Matrixd mtxdR; mtxdR.makeRotate(q);
  osg::Matrixd mtxdT; mtxdT.makeTranslate(ov3d);
  osg::Matrixd OriginalPositionMatrixd = mtxdR * mtxdT; //order matters!!!!

MY PROBLEM:  
when I attempt to rotate about "y-axis" or "z-axis" which I think are local to 
the focalPt, the rotation is totally wrong.
It rotates in an completely unexpected way.

Would someone please explain to me how to properly construct a local origin at 
my focal point so that I can rotate my model, 
which is at that point, around the local x,y and z axes?  
I am on the surface of the Earth, too, and I want to actually rotate my model 
about it's "z-axis" so as to change the azimuth the model is facing.

Note: whether the axes are normalized or not seems to make no difference though 
I think that that should make a difference.
... 

Thank you very much!

Cheers,
Allen

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to