Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Quaternion to Euler xyz

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    2

    Quaternion to Euler xyz

    I have looked in a lot of places and have been unable to find and answer to this problems, so I thought I might try here. Anyway, I am loading up a 3D file that uses quaternion to rotate object (I am programming in C++). I need to convert this rotation into a euler rotation. The rotation of the euler goes X then Y then Z. I don't know much about quaternion rotations, but I just need to make a function that takes in w,x,y,z in quaternion and puts out the equivalent euler x,y,z. Is this possible? I don't really know much about how the file stores the quaternion rotations, but as a test, I exported something with a rotation and found what the file said the quaternion is.
    I got the following:
    In: 90,1,0,0 File: 1.570796, -1.000000 0.000000 0.000000
    In:180,1,0,0 File: 3.141593, -1.000000 0.000000 0.000000
    This makes sense. It's just exporting in radians not degrees. But, when I run any of the converters that I have found so far I get results that are way off.
    Out:-135.000000 0.000000 0.000000
    Out:-116.565041 0.000000 0.000000
    I don't think I need to post the code because it is clearly wrong. I just want to start clean. Could someone post a c++ source, a link to the source or at least a tip to point me in the right direction. That would be great.
    Hopefully this is enough information.
    Thanks in Advance for the help.

  2. #2
    Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    298

    Re: Quaternion to Euler xyz

    You might try taking a look at the Wild Magic library. He has routines for going back and forth between quaternions, rotation matrices and euler angles.

    Relevant files are:

    http://www.geometrictools.com/LibFou...m4Quaternion.h

    and

    http://www.geometrictools.com/LibFou...s/Wm4Matrix3.h

    You can get the code either by buying the book or maybe scraping the website??
    If you want to go this way I can testify that the math library is very 'stand-alone' and you can
    easily incorporate the parts you want.

    Just a thought...


  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    130

    Re: Quaternion to Euler xyz

    This is probably the best resource to understand (and implement) the various rotation formats, including quaternion, Euler, matrix and so on:
    http://www.euclideanspace.com/maths/...ions/index.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •