Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Combining Rotations

Started by Yratelev Jan 20, 2005 at 7:41 AM 1 replies 900+ views
Original Post
Yratelev
Yratelev
Hi, I've naively adopted the physics representation if a rotation, which is a vector in the direction of the axis of rotation and length of the angle of rotation. I combine these rotations by adding the vectors. This seems to kinda look ok in a simulation, but its not correct (because Quaternion combining of rotation is not commutative, but my idea is commutative). Ive tried using quaternions, but they have a wrap-around problem. If an object is rotating at 2*Pi degrees a second (ie a complete rotation) then that produces a Quaternion representation of the Identity Quaternion. Now if i update every have second, the object should rotate by Pi each frame. However, scaling the Identity Quaternion just reproduces the Identity again. Anyone have theses problems, or more importantly a solution? Any help in disproving my naive approach, and why it doesnt work would be great help thanks Yratelev
Yratelev
johnb
johnb
Use a smaller time step. No matter what representation you use if you only update every second and your objects can rotate by a full turn in that time then you will have problems. Storing angles > 360 degrees will not help as it makes comparing and calculating rotations more difficult and expensive, apart from the problems you've already encountered.

Most games either use the game frame rate or (if that is too variable) an independent clock to determine how often to update object dynamics. Typically this runs at 30+ Hz/times a second, more than fast enough that in a reasonable simulation the problem you've described don't arise.

John BlackburneProgrammer, The Pitbull Syndicate
JohnBolton
JohnBolton
The problem is that for any rotation, there is no way to determine how it got there. For example, you have a 45 degree rotation. There are infinite half rotations that will get you there: 22.5 degrees, -157.5 degrees, 202.5 degrees, ...

Now, with an axis-angle representation you can apply some criteria to pick an acceptable amount of rotation. But you can't with quaternions because the rotation angle isn't explicit. So to apply that same criteria, you must convert to axis-angle, apply the criteria, then convert back.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.