PDA

View Full Version : Rotating around a World Space Axis - How Works?



subkey
04-20-2012, 07:41 PM
I have a cube that I am successfully rotating by mouse drags with the following algorithm:

1) Initialize rotation matrix to identity

2) Multiply world-space y-axis (0, 1, 0) by inverted rotation matrix to get a vector in object space corresponding to the y-axis. Then rotate a bit around this vector given the mouse drags.

3) Same thing for x-axis.

4) Each update, apply rotation matrix to object.

This works fine, I am just having trouble understanding the theory behind why you can get the y-axis in object space by multiplying the y-axis in world space by the inverted rotation matrix. Can anyone explain this in very simple terms - I must be missing a key concept.

Thanks!

Dark Photon
04-21-2012, 01:25 PM
I am just having trouble understanding the theory behind why you can get the y-axis in object space by multiplying the y-axis in world space by the inverted rotation matrix. Can anyone explain this in very simple terms - I must be missing a key concept.

(MODELING TRANSFORM) * (object space vec) = (world-space-vec), i.e.
(MODELING) * object = world

multiply both sides by the inverse modeling transform:

(MODELING)-1 * (MODELING) * object = (MODELING)-1 * world, i.e.
object = (MODELING)-1 * world

The rotation is your MODELING transform.

(...or at least it is your MODELING transform with any translation removed.)

subkey
04-22-2012, 12:11 PM
@Dark Photon: That helps a *lot*, thanks so much! :]