# Rotating around a World Space Axis - How Works?

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!

(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.)

@Dark Photon: That helps a lot, thanks so much! :]