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

Thread: Rotation Vectors

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Bolton, United Kingdom
    Posts
    26

    Rotation Vectors

    Hi,

    I'm looking for advice / solution to a fairly minor problem that my tired
    brain can't figure out. I need to rotate an object from a rotational vector
    (xs, ys, zs) to a target vector of (xd, yd, zd) in incremental steps to
    achieve animated rotation. My initial solution was simply to subtract one
    vector from the other and divide the result by a factor that determined the
    number of rotational increments. Now all worked but I noticed that there
    were occasions when an object would rotate through a larger angle than was
    needed.

    If you consider an object with an x rotation of 270 and you want it to
    rotate to 0 then my result requests a rotation of -270 whereas 90 degrees
    would have been the quicker move ! I'm looking for a general solution that
    provides me with the minimum solution and copes with all angles i.e. -90 is
    the same as 270 as is -180 and 180 ...

    (I can't believe that I can't get my head around this one ... especially
    after deriving a Quaternion based camera class !)


    I look forward to hearing from you ...

    Many thanks

    Andrew

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Rotation Vectors

    The axis of rotation should be the cross product of the two vectors. The rotation ammount should be the arccossine of the dot product of the two vectors divided by the number of iterrations. You may have to negate the rotation angle or an input vector.

Posting Permissions

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