Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to sum rotations (vector + angle) ??

Started by arkangel2803 Jul 30, 2009 at 4:40 PM 5 replies 15.9k views
Original Post
arkangel2803
arkangel2803
Hi all I think its a simple question, but i find nothing on forum yet :( I am programming static animations, and all meshes have initial translation, rotation and scale, and then, another translate + rotate + scale is interpolated from a static animation and added to the first one. The problem comes with rotation, look: - Final translation = Initial translation + Static Anim. Interpolated translation. - Final Scale = Initial scale * Static Anim. Interpolated scale. - Final rotation = ??? Is there any easy way to calculate the sum of two rotations from his vectors and angles ? Now i am doing this calculating the first matrix, then de interpolated rotation matrix and multiplying toghether. Thanks in advance for your time :) LLORENS
Zakwayda
Zakwayda
If your rotations are represented using matrices or quaternions, they can easily be combined ('added') through multiplication. As for interpolation of rotations, you can use SLERP or NLERP. Each method can be used with both matrices and quaternions, but the quaternion versions of these algorithms are considerably more efficient.

Does that help at all?
arkangel2803
arkangel2803
Hi jyk

I think no, because i dont use quaternions to make rotations, i use the basic idea of a vector representing rotation axis and angle.

For example:

Rotation 1: vector (1.0f, 0.0f, 0.0f) angle 90º
Rotation 2: vector (0.0f, 1.0f, 0.0f) angle 80º

If we do this, we first rotate the object on his x axis with 90º in a left hand rotation.

Then, we rotate the object on his y axis with 80º in a left hand rotation.

IS there an easy way to 'sum' these rotations in one vector and one angle ?

Thanks in advance :)

LLORENS
Zakwayda
Zakwayda
Quote:
Original post by arkangel2803
Hi jyk

I think no, because i dont use quaternions to make rotations, i use the basic idea of a vector representing rotation axis and angle.

For example:

Rotation 1: vector (1.0f, 0.0f, 0.0f) angle 90º
Rotation 2: vector (0.0f, 1.0f, 0.0f) angle 80º

If we do this, we first rotate the object on his x axis with 90º in a left hand rotation.

Then, we rotate the object on his y axis with 80º in a left hand rotation.

IS there an easy way to 'sum' these rotations in one vector and one angle ?

Thanks in advance :)

LLORENS
The fact that your rotations are represented in axis-angle form doesn't mean you can't use matrices or quaternions. First of all, you can always convert back and forth between representations if needed; second of all, you'd probably be better off using matrices or quaternions as your basic representation, rather than axis-angle pairs.

As for concatenating rotations in axis-angle form, it can be done, but what you end up with is basically a matrix multiplication written out longhand. That being the case, it would really be much easier just to use matrices (or quaternions) directly.
mmakrzem
mmakrzem
Convert each of your rotations into a matrix
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm

Multiply both matrices together.

Convert the result back to an axis-angle represenation and you're done.
bigneilm3
bigneilm3
You can't concatenate to perform translations and rotations separately, you have to Rotate, Translate, Rotate Translate (in that order) on the same matrix (ex. glTranslate and glRotate for a parent and child). Scales can be multiplied together. See my recent post at:

http://www.gamedev.net/community/forums/topic.asp?topic_id=544049
RobTheBloke
RobTheBloke
Quote:
Original post by mmakrzem
Convert each of your rotations into a matrix
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm

Multiply both matrices together.

Convert the result back to an axis-angle represenation and you're done.


Or do it as quats, which will be far more efficient and require much less code ;)

Quote:
You can't concatenate to perform translations and rotations separately, you have to Rotate, Translate, Rotate Translate (in that order) on the same matrix (ex. glTranslate and glRotate for a parent and child). Scales can be multiplied together. See my recent post at:

http://www.gamedev.net/community/forums/topic.asp?topic_id=544049

The OP makes no mention of concatenating matrices. He asked only how to interpolate two rotations.

Topic Locked

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

Sign in to reply to this topic.