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 4 of 4

Thread: converting a 3D vector into three euler angles?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Wichita, KS, USA
    Posts
    23

    converting a 3D vector into three euler angles?

    In 2D you can view a point's X,Y coordinates as a vector and that vector can be thought of a describing a direction from the origin -- or a rotation around the origin.

    To get the 2D angle of rotation you can do:
    angle = tan(y/x);

    Easy, but how do you do it with a 3D vector? I know in 3D you need three angles to represent any possible direction. Seems like there should be three simple trig equations for finding these angles when you have X,Y,Z but I can't seem to find the right Google phrase to search for today.

    Please help!

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Wichita, KS, USA
    Posts
    23

    Re: converting a 3D vector into three euler angles?

    *Oops*

    Just remembered that a lone 3D vector can't fully describe three Euler angles. Maybe two angles, but that's it.

    That would explain why I can't find any info on how to do it! I'll try a matrix method.

    NEVER MIND

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    Tokyo
    Posts
    2

    Re: converting a 3D vector into three euler angles?

    There's a way, by considering the length of the vector as an angle. Then you just convert an axis/angle to euler angles, which is pretty usual. In fact this is one way Exponential Map can be coded.

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2004
    Posts
    1

    Re: converting a 3D vector into three euler angles?

    You can post it in 3D coordinates. You must think of a sphere, rather than just a circle.
    Let r = radius, t = angle on x-y plane, & p = angle off of z-axis. Then you get:

    x = r * sin(p) * cos(t)
    y = r * sin(p) * sin(t)
    z = r * cos(p)

    If you already have x,y,z and want to switch it back, this is the conversion:

    r = sqrt(x*x + y*y + z*z)
    t = arctan(y/x)
    p = arccos(z/r)
    *For computing p, it's easier to compute r first, then use it as the denominator (assuming ![x = y = z = 0]).

Posting Permissions

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