Accumulating Transformations & Rotations

Hello once again from the world of insanity!

Today’s question is:

How does one go about accumulating rotations and transformations on a model/object?

In essence, You have an object, say a cube. What you want to do is accumulate transforms (or save the state) of the object across frames.

Obviously you need some sort of storage object to do this, but what is the best solution?

Secondly, accumulating rotations. What is the best way to resolve this (aside from quaternions, which I do not want to implement)? Basically, what needs to be done is that Object A is in a given orientation. You wish to rotate Object A by an arbitrary vector and angle (usually, the angle will be 1 degree in this case).

Diving back into the original question, after this rotation, this is the new “permanent” orientation for Object A. Now any transforms must be made upon this orientation as if the model was constructed in this orientation originally.

How do I go about doing this in the simplest way possible?



If you want to rotate in steps of one degree it is beter to start with the identity matrix and increase the angle by one degree, every time, than acumulating rotations.


Search for “Euclidean Rotation
Matrix”. Basically, there’s a good article
there which shows that you can stay in
normal Euclidean 3D space (using 4x4
matrices) and still do everything Quaternions
do, only faster and cheaper :slight_smile:

So, for each object, you keep not a matrix,
but the rotation/translation values. Then
when time comes to render, you plug those
values into the transform and rotate matrices
and out comes the transform for the object
for that frame. This costs no more than
keeping an accumulated transform matrix,
because in either case, you’re touching all
of the vertexes and doing a full matrix

You could keep the current matrix and perform the rotations and translations manually (multiplying the proper matrices), storing the result to be used next time by loading it and then have the proper calls to glMultMatrix to get the next result.

remember: if you rotate something, then translate it out the next rotation will still rotate about 0,0,0 and not the center of the object. If you want to keep rotating it about it’s center it would be easier to simply keep the angle(s) in variable(s) and apply glRotatef as needed for each angle or multiply by one matrix containing all the agles for the rotation, then continue with translations etcetera.