# 3x3 Rotation matrix from various angles

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

Here is the 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.

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.

-
The direction of B is unaffected by applying the rotation of C, yes? – El'endia Starman May 10 '11 at 0:23
Yes correct. C rotation is applied first. A/B is then applied to the rotated object. – Zoom May 10 '11 at 1:57
So... you are now rotating with respect to which axis after the $C$ rotation? – J. M. is back. May 13 '11 at 0:45
A is the angle away from the z axis. B is the direction that is applied in. – Zoom May 13 '11 at 1:03
Nono, you misunderstand my query, it seems. Whenever we rotate something, you rotate with respect to some imaginary line passing through your object, yes? (think of holding a barbecue and rotating the stick) What is that imaginary line you're rotating your object on? That should assist in determining the proper rotation matrix. – J. M. is back. May 13 '11 at 1:50

$$\begin{pmatrix} xxt+c&xyt-zs&xzt+ys\\ yxt+zs&yyt+c&yzt-xs\\ zxt-ys&zyt+xs&zzt+c\end{pmatrix}$$
\begin{align*} x &= \cos(B + 90°)\\ y &= \sin(B + 90°)\\ z &= 0\\ s &= \sin(A)\\ c &= \cos(A)\\ t &= 1 - c \end{align*}
...and if you'll finally indulge me a tiny numerical note: the formula for $t$ is numerically unsound if $A$ is tiny. Rather, use $t=2\sin^2\frac{A}{2}$. – J. M. is back. May 14 '11 at 4:49