In 3D transformations, Rotation Transformations are often used, and many transformations are centered around any axis. The following describes two methods to rotate around any unit axis.
Assume that the angle to be rotated is A, and the axis around it is R.
Method 1:
(1) build a new foundation
Find the coordinate axes S and T in the other two units of length. They are vertical to each other and vertical to R. In this way, R, S, and t form a group of new bases.
The specific method of S:
Find the minimum component in R, set it to 0. Then swap the other two components, and then reverse the first non-zero component (in fact, you can also reverse the other non-zero component ).
T is required. Only cross product of R and S is required.
Detailed formula:
This ensures that R, S, and t constitute a group of orthogonal unit bases.
(2) transform the standard base to the new base.
The R and x axes must be overlapped by transformation, so that the subsequent rotation is the normal rotation around the X axis. The other two axes also overlap.
The transformation matrix consists of the preceding R, S, and t vectors:
(3) Rotating
Because R overlaps with X, in the new base, we only need to rotate around the X axis (normally rotating.
Assume that the rotation matrix is rx ().
(4) return to the original standard base.
The transformation matrix should be M's inverse matrix. Because m is orthogonal, its inverse matrix is its transpose matrix.
Therefore, the final transformation matrix around any unit axis is:
Method 2
According to the formula given by Goldman, this formula is a bit complicated:
For detailed derivation process, refer:
Http://www.cppblog.com/lovedday/archive/2008/01/12/41031.html
http://www.cnblogs.com/cg_ghost/archive/2012/04/27/2473347.html