Recently I came across the problem of rotating an object in 3d realtime application around its local axis. To give the answer instantly: It is done like rotation around world axis but in reverse order of rotations.
Usually you will use the standard rotation matrices around X, Y, Z axis to rotate a point or vector around the respective world axis. Instead rotating around a local axis rotates the object around an axis that already has been rotated before. So local rotation only makes sense for consecutive rotations. If you only do one rotation on an object that has not been rotated so far, local and global axis are equal.
Local rotation is equal to world rotation in reverse order. Why? This can be explained by looking at the way rotation matrices change vector basis. According to this article we observed that a rotation matrix does a vector basis change from the rotated basis it represents to the standard basis or more general to the basis the coordinates of the vector or point you rotate are related to. This is the reason why the standard rotation matrices always do a world like rotation. They do not transform the vector or point to its rotated coordinate system. Local rotation instead has to describe a rotation in respect to the coordinate system of the before applied rotation. Consider two rotations and applied to a vector :
In that order the rotation would be applied first and afterwards. Now we want to perform a local rotation. Local means here that is done in respect to the rotated vector basis represents. In order to transform coordinates into the vector basis of a rotation matrix we have to apply the inverted rotation matrix. For this example this looks like this:
But from the moment that we apply we are working in the coordinate system of . So we have to transform back to the original coordinate system was defined in by applying once again after doing the local rotation:
This is the full term now, but we see that equals the identity matrix and thus can be cut out. This gives the final result:
So the order of rotations has just changed in order to apply as a local rotation, what proves the above given solution to the problem. This change of order gives us another hint on consecutive rotations: If you have a matrix multiplication representing consecutive rotations you can always interpret it in both directions: From left to right (like you read) every rotation is applied on local axis. From right to left every rotation is applied on world (global) axis. Again: These are possible interpretations of a series of rotations. The nice thing here is that we still only use the standard rotation matrices and do not have extra costs but just change the order.
Author: Michael Keutel | 11.05.2015