0
101 May 01, 2009 at 10:04

Hey,

Kinda related to my previous post about Quaternions…

Please correct me if im wrong, but with Axis angle you will be storing X,Y,Z, Angle and when you want to carry out your rotations, lets say in OpenGL you would do:

glRotatef(Angle, X,Y,Z);

So if you were to purely use Axis Angle for a camera system how do you go about adding together the rotations?

From most camera systems ive looked at you either do the rotations every time you change direction (i.e looking up, or looking left), or you accumulate the rotations then on your update you generate the combined rotation.

Although im just a bit puzzled as to how you would do this with Axis angle, as if i wanted to rotate 90 degrees left, then 90 degrees up, if i was to just add the angles together that would end up being:

glRotatef(180.0f, 1.0f, 1.0f, 0.0f);
Not sure if im meant to convert to radians for the rotation or not… but you see the logic…

Im just thinking if by some miracle you were able to do 300 degrees left 90 degrees up and finally 10 degrees roll in one update period you would then end up with:

glRotatef(400.0f, 1.0f, 1.0f, 1.0f);

Now i would probably just deduct 360.0f from it if it went over 360 degrees, but would this be a valid rotation?

glRotatef(40.0f, 1.0f, 1.0f, 1.0f);

Not sure if im talking sense or not, but if anyone has time and patience to answer or give any advice it would be great :D i basically just want to know how to add and track rotations purely with Axis Angles, incase i went off topic a bit…

#### 2 Replies

0
167 May 01, 2009 at 17:34

Sadly there’s no simple formula for composing rotations using the axis-angle representation. The easiest way to do it is convert both rotations to matrices or quaternions, multiply them, then convert them back.

For this reason I generally find that axis-angle representation is not a very useful form for representing rotations in 3D graphics. (It is useful for representing angular velocity in physics, but that’s a different story.)

That being said, depending on the type of camera you’re making you may not actually need to compose arbitrary rotations. For instance, an shooter-style camera works by just maintaining a yaw and pitch, which the player’s controls affect directly, then recalculating the rotation matrix each frame from those. On the other hand, for a 6DOF camera for a flight simulator or space simulator, you’d need the full machinery of arbitrary rotations.

By the way (don’t know if this is relevant or if you already know), the glRotatef function internally just converts its input to a matrix immediately, and multiplies it onto the current OpenGL modelview or projection matrix.

0
101 May 02, 2009 at 02:27

Didnt know that, but thats good to know… im just about to post one more question relating to this field then i *think* im done… :D