[Math] 3×3 Rotation matrix from various angles

geometrymatrices

I am getting 3 angles from another system that I need to convert into a 3×3 rotation matrix.

Here is the diagram:

diagram

P is the point where all angles are 0.
A is the tilt angle limited to the angles 0 to 90 degrees.
B is the angle that A is applied in. Note B does not rotate the object itself. If A's value is zero then this angle does nothing. Range is 0 to 180 anticlockwise and 0 to -180 clockwise.
C is the rotation around P. Same ranges as B. This rotation is applied first.

In short, rotate object around P by C, then tilt by A in the direction of B.

Let me know if you need more info.

Edit:
I'll start off with what I have got already and that is the C rotation. Pretty easy for that one as it is just the rotation around the Z axis.

$$\begin{pmatrix}
\cos(C)&-\sin(C)&0\\
\sin(C)&\cos(C)&0\\
0&0&1\end{pmatrix}$$

That works for my purposes but I am unsure of how to convert the other angles to a matrix so I can multiply the two together.

Best Answer

After J. M.'s comment it occurred to me that I can make B + 90 degrees the arbitrary axis and spin in the amount of A. So I can use that to get an axis-angle rotation and then convert that to a matrix.

$$\begin{pmatrix} xxt+c&xyt-zs&xzt+ys\\ yxt+zs&yyt+c&yzt-xs\\ zxt-ys&zyt+xs&zzt+c\end{pmatrix}$$

Where:
$$\begin{align*} x &= \cos(B + 90°)\\ y &= \sin(B + 90°)\\ z &= 0\\ s &= \sin(A)\\ c &= \cos(A)\\ t &= 1 - c \end{align*}$$

Multiplying this matrix with the C matrix in the question above give the correct rotation matrix.