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

Thread: Can a quaternion represent more than 360 degrees of rotation?

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    28

    Can a quaternion represent more than 360 degrees of rotation?

    I like Euler rotation based on degrees so I can keyframe an animation of a large number of degrees, like 1000, and get multiple full 360-degree revolutions on the object for purposes of setting it spinning, etc.

    However I'm at a point now when I was working on something that involved a lot of consecutive animations among two different axes that I think I'm seeing the effects of gimbal lock. When I perform one of the chained animations, my object keeps flipping 180 degrees after it completes a 90-degree rotation. Does this sound like gimbal lock? It only happens after other prior and successful rotations along different axes.

    In any case, I tried switching to Quaternions but it appears that quaternions aren't suited for this spinning effect, since they just get you an orientation and they treat a multiple of 360 as 0 using this:

    Code :
    template <typename T>
     inline QuaternionT<T>  QuaternionT<T>::CreateFromAxisAngle(const Vector3<T>& axis, float radians)
     {
    QuaternionT<T> q;
    q.w = std::cos(radians / 2);
    q.x = q.y = q.z = std::sin(radians / 2);
    q.x *= axis.x;
    q.y *= axis.y;
    q.z *= axis.z;
    return q;
    }

    Is it possible to get more than 360 degrees of rotation from a quaternion technique?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    I like Euler rotation based on degrees so I can keyframe an animation of a large number of degrees, like 1000
    Why do you need keyframes far enough apart that this is necessary? Generally speaking, keyframes should only be at most 1/10th of a frame apart. You shouldn't be able to spin 1080 degrees in less than one tenth of a second.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    28
    Sorry, you misunderstand. I can set a single animation to last, say, 10 seconds, and in that 10 seconds I get 5 full revolutions, or 360*5 degrees. That is what I meant. But I gather this is not possible with quaternions.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    You're simply doing it the wrong way. If you have a single animation that lasts 10 seconds and during that time, you have a 5 360 degree revolutions, then what you have is a single animation that lasts 10 seconds, where every 1/30th of a second, you rotate the object 6 degrees.

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    28
    Why is this "wrong" to rotate an object 6 degrees each keyframe? It looks fine and works well.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Why is this "wrong" to rotate an object 6 degrees each keyframe?
    ... What are you talking about? I was the one who suggested that you rotate it 6 degrees every 1/30th of a second. I didn't say that it was wrong.

    What's wrong is thinking of the rotation as 1800 degree in 10 seconds. They're both functionally the same, but the smaller one uses smaller numbers, so you don't have to deal with rotations that quaternions can't handle.

    The way you're doing it is to attempt to create a quaternion for a 1800 degree rotation, then dividing that quaternion by time. You instead should be dividing the rotation by the time, and constructing a quaternion to rotate the object based on how much time elapsed since the last time you did that. You update the orientation by the delta quaternion.

  7. #7
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    28
    Ah I see what you're saying, thanks.

Tags for this Thread

Posting Permissions

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