Shayne,
After retrieving the Quat orientation with getRotate you can use this
snippet:
osg::Vec3d getHPRfromQuat(osg::Quat quat){
        // From: http://guardian.curtin.edu.au/cga/faq/angles.html
        // Except OSG exchanges pitch & roll from what is listed on that
page
        double qx = quat.x();
        double qy = quat.y();
        double qz = quat.z();
        double qw = quat.w();

        double sqx = qx * qx;
        double sqy = qy * qy;
        double sqz = qz * qz;
        double sqw = qw * qw;

        double term1 = 2*(qx*qy+qw*qz);
        double term2 = sqw+sqx-sqy-sqz;
        double term3 = -2*(qx*qz-qw*qy);
        double term4 = 2*(qw*qx+qy*qz);
        double term5 = sqw - sqx - sqy + sqz;

        double heading = atan2(term1, term2);
        double pitch = atan2(term4, term5);
        double roll  = asin(term3);

        return osg::Vec3d( heading, pitch, roll );
}
--
Roland
 


________________________________

        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
        Sent: zaterdag 22 november 2008 0:52
        To: OpenSceneGraph Users
        Subject: [osg-users] extracting heading, pitch, roll from
rotation matrix...
        
        

        Is there any method or class in OSG that extracts heading,
pitch, and roll angles from a rotation matrix?

         

        I've searched and haven't seen anything. I just want to make
sure there isn't anything out there before I embark on writing my own...

         

        Thanks in advance,

        -Shayne

This e-mail and its contents are subject to the DISCLAIMER at 
http://www.tno.nl/disclaimer/email.html
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to