Hi Jason,

here you have YPR from osg::Quat (look at the snippets)

http://forum.openscenegraph.org/viewtopic.php?t=548

As for the other way it is easy, you create the Matrix and get the rotate
Quat, (return matrix.getRotate()), something like:

osg::Matrixd Utils::createMatrix(double x, double y, double z, double h,
double p, double r)
{
    osg::Matrixd mxR;
    mxR.makeRotate(osg::DegreesToRadians(r),osg::Vec3(0,1,0));
    osg::Matrixd mxP;
    mxP.makeRotate(osg::DegreesToRadians(p),osg::Vec3(1,0,0));
    osg::Matrixd mxH;
    mxH.makeRotate(osg::DegreesToRadians(h),osg::Vec3(0,0,1));
    osg::Matrixd mxT;
    mxT.makeTranslate(osg::Vec3(x,y,z));

    return (mxP*mxH*mxT*mxR);
}

On Thu, Dec 18, 2014 at 12:03 AM, Jason Anderssen <janders...@exactal.com>
wrote:
>
>  Hi Chris,
>
>  Thank you for you reply.
>
>  I had a look at those, maybe I can get it to work with them, but I
> really just want a simple 3 values for Yaw Pitch and Roll, from which I can
> re-create the exactly same Quat or Matrix.  I will also clarify, I don't
> care about translation or scale etc, and the quaternion I am using is of
> course only a rotation anyway.
>
>  So basically I want the following type of code :
>
>  getYPR(float &yaw, float &pitch, float &roll);
>
>  Quaternion::fromYPR(yaw, pitch, roll);
>
>  Cheers
> Jason Anderssen
>
>   From: Chris Hanson <xe...@alphapixel.com>
> Reply-To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
> Date: Wed, 17 Dec 2014 15:47:57 -0700
> To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
> Subject: Re: [osg-users] Yaw pitch and roll or xyz conversion to and from
> Quaternion
>
>    Just wondering if in OSG there is anywhere I can extract either Yaw
>> pitch and roll / or XYZ eular angles, too and from either a matrix or a
>> quaternion?
>>
>
>    The
>   void
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01593.html#a306a73ea16dfe10406725cefb3867dfa>
>   get
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00648.html#a341e0295def3df6e07a014a1ff8195b4>
>  (Matrixd
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00489.html>
>  &matrix)
> const
>
>  method lets you convert a Quat to a 4x4 Matrix.
>
>    void
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01593.html#a306a73ea16dfe10406725cefb3867dfa>
>   decompose
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00489.html#a3aad163d793a9d5af248e42fd2e94dea>
>  (osg::Vec3d
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00972.html>
>  &translation, osg::Quat
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00648.html>
>  &rotation, osg::Vec3d
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00972.html>
>  &scale
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00489.html#a9a9ad7cd3f007df5f559e10d471f1981>
> , osg::Quat
> <http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00648.html>
>  &so)
> const    decompose the matrix into translation, rotation, scale and scale
> orientation.
>
>  Will extract the trans, rot and scale components out of the matrix.
>
>  Is that what you want?
>
>  --
>  Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
> http://www.alphapixel.com/
> Training * Consulting * Contracting
> 3D * Scene Graphs (Open Scene Graph/OSG) * OpenGL 2 * OpenGL 3 * OpenGL 4
> * GLSL * OpenGL ES 1 * OpenGL ES 2 * OpenCL
> Digital Imaging * GIS * GPS * osgEarth * Terrain * Telemetry *
> Cryptography * Digital Audio * LIDAR * Kinect * Embedded * Mobile *
> iPhone/iPad/iOS * Android
> @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
> 623-PIXL [7495]
>   _______________________________________________ osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> Internet
> Email Confidentiality Footer: This email and any files transmitted with it
> contain privileged/confidential information intended for the addressee.
> Neither the confidentiality of nor any privilege in the email is waived,
> lost or destroyed by reason that it has been transmitted other than to the
> addressee. If you are not the addressee indicated in this message (or
> responsible for delivery of the message to such person), you may not copy
> or deliver this message to anyone. In such case, you should destroy this
> message, and notify us immediately.
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>

-- 
trajce nikolov nick
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to