This type of question has been asked before, but I haven't been able to find a satisfactory explanation. Perhaps I'm just a bit slow...
Say that I have a global right-handed coordinate system represented by X, Y, and Z. Say then that I have a rotated cube whose lower, left, back corner defines the origin of a new right-handed coordinate system and whose sides connecting to the origin define the X', Y', and Z' axes. Next we define the angle between X and X' as alpha, the angle between Y and Y' as beta, and the angle between Z and Z' as gamma.
I would like to be able to use rotation matrices and the angles alpha, beta, and gamma to define the coordinates of the rotated cube in the X, Y, and Z global coordinate system. These rotation matrices are given by:
Rx = [[1, 0, 0], [0, cos(alpha), -sin(alpha)], [0, sin(alpha), cos(alpha)]]
Ry = [[cos(beta), 0, sin(beta)], [0, 1, 0], [-sin(beta), 0, cos(beta)]]
Rz = [[cos(gamma), -sin(gamma), 0], [sin(gamma), cos(gamma), 0], [0, 0, 1]]
For example, a rotation about the z-axis for a vector X in R3 gives a new vector x by:
x = Rz * X
These rotation matrices work perfectly well and order of matrix multiplication does not matter when two of the three rotation angles are zero e.g. when alpha≠0 and beta=gamma=0 or beta≠0 and alpha=gamma=0 or gamma≠0 and alpha=beta=0. This is because when the rotation angle for a particular rotation matrix is equal to 0 the rotation matrix becomes the identity matrix.
The order of these matrices matters when more than one of the rotation angles are nonzero. My understanding is that for the following rotation:
x = Rz * Ry * Rx * X
represents a rotation about the x-axis, then a rotation about the new y-axis, and then a rotation about the new new z-axis.
Is there an order of these rotations that does what I would like? Or a relation in order to do so? In summary, I would like a relation to be able to rotate these based only on the angles between X' and X, Y' and Y, and Z' and Z.