rot(z,th1)rot(z,th2) = [ c1 -s1 0 0 ] [ c2 -s2 0 0 ] [ s1 c1 0 0 ] [ s2 c2 0 0 ] [ 0 0 1 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ] [ 0 0 0 1 ] = [ c1c2-s1s2 -c1s2-s1c2 0 0 ] [ s1s2+c1c2 -s1s2+c1c2 0 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ] =rot(z,th1+th2)
[ 0 0 1 0 ] [ 0 -1 0 0 ] [ 1 0 0 0 ] [ 0 0 0 1 ] or, equivalently as a 3x3 matrix [no translations occur, so a 3x3 matrix could be used to represent the transformation in 3D cartesian coordinates, instead of the usual 4D homogeneous coordinates] [ 0 0 1 ] [ 0 -1 0 ] [ 1 0 0 ](only the rotational part of the matrix matters in this case)
trans(1,0,0) rot(z,45) rot(x,theta) rot(z,-45) trans(-1,0,0)
The key is to move any part of the axis q so that it passes
through the origin, then align the axis with the origin,
do the desired rotation, and undo everything.
-1 -1 -1 -1 (A B C) = C B A = rot(y,-beta) rot(z,-alpha) trans(-a,-b,-c)
We can express the matrix
[ Ax Bx Cx Tx ] [ Ay By Cy Ty ] [ Az Bz Cz Tz ] [ 0 0 0 1 ]as a two-by-two matrix,
[M T] [0 1]where each element is not just a number, but a matrix in itself: M is a 3x3 rotation matrix, T is a 3x1 matrix, 0 is a 1x3 matrix, and 1 is just 1.
Now we use an analogy with a two-by-two matrix of numbers, and its inverse:
-1 -1 [a b] = (ad - bc) [ d -b] [c d] [-c a]hence we expect that
-1 -1 [M T] = (M1 - 0T) [ 1 -T] [0 1] [-0 M]but
-1 -1 (M1 - 0T) = Mso
-1 -1 -1 -1 [M T] = M [ 1 -T] = [M -M T] [0 1] [-0 M] [0 1 ]now M is orthogonal, so its inverse is its transpose:
-1 t M = Mso our final result is:
-1 t t [M T] =[M -M T] [0 1] [0 1]
[ 1 0 0 0 ] [ ? ? ? ? ] [ Ax Bx Cx Tx ] [ 0 1 0 0 ] = [ ? ? ? ? ] [ Ay By Cy Ty ] [ 0 0 1 0 ] [ ? ? ? ? ] [ Az Bz Cz Tz ] [ 0 0 0 1 ] [ ? ? ? ? ] [ 0 0 0 1 ]Now let's use the facts we know, namely that A,B,C are an orthonormal set of vectors. Thus each of A,B,C is of unit size, and they are all at right angles to each other:
A.A = 1 A.B = 0 A.C = 0 B.B = 1 ... etcWriting the equation for element (1,1) gives:
A.? = 1One possible solution is to let ? = A.
[ 1 0 0 0 ] [ Ax Ay Az ? ] [ Ax Bx Cx Tx ] [ 0 1 0 0 ] = [ Bx By Bz ? ] [ Ay By Cy Ty ] [ 0 0 1 0 ] [ Cx Cy Cz ? ] [ Az Bz Cz Tz ] [ 0 0 0 1 ] [ ? ? ? ? ] [ 0 0 0 1 ]Note that the zeroes in the top-left 3x3 corner of the identity matrix are also satisfied. For example, for element (1,2):
0 = Ax*Bx + Ay*By + Az*Bz + ?*0 = A.B = 0Placing [ 0 0 0 1 ] in the bottom row satisfies the equations arising from the bottom row of the identity matrix.
Lastly, we have the following equations:
0 = Tx*Ax + Ty*Ay + Tz*Az + ? 0 = Tx*Bx + Ty*By + Tz*Bz + ? 0 = Tx*Cx + Ty*Cy + Tz*Cz + ?From the above, the uknowns can be directly determined as
-T.A -T.B -T.CThe final result is thus:
[ 1 0 0 0 ] [ Ax Ay Az -T.A ] [ Ax Bx Cx Tx ] [ 0 1 0 0 ] = [ Bx By Bz -T.B ] [ Ay By Cy Ty ] [ 0 0 1 0 ] [ Cx Cy Cz -T.C ] [ Az Bz Cz Tz ] [ 0 0 0 1 ] [ 0 0 0 1 ] [ 0 0 0 1 ]