# 3D Vector Rotation Matrix with Radians

I have been working on a simple C++ vector library and needed 3D rotation so I found these 3D rotation matrices on Stack Overflow:

x-axis
|        x        | = |x'|
|y cos θ − z sin θ| = |y'|
|y sin θ + z cos θ| = |z'|
y-axis
|z sin θ + x cos θ| = |x'|
|        y        | = |y'|
|z cos θ - x sin θ| = |z'|
z-axis
|x cos θ - y sin θ| = |x'|
|        y        | = |y'|
|x sin θ + y cos θ| = |z'|


However, these matrices are for degrees and not radians. I realized I could find the sine and cosine of the radians converted to degrees and reconvert the values after the matrix transformation back into radians (i.e. convert the radians into degrees and back again), but I am still curious about what the matrices would be for radians. What would they be?

• The value of $\sin{(\theta)}$ is the same no matter whether we use 'angles' or radians - What do you mean? – Peter Foreman Feb 17 at 21:08
• @PeterForeman Degrees! Why do I keep on thinking of degrees as angles? – Brendon Shaw Feb 17 at 21:13
• @PeterForeman I am getting my terms mixed up right now. Sorry about that. – Brendon Shaw Feb 17 at 21:15
• A more general tip: if a formula in degrees is neat, without powers of $\pi/180$ anywhere, it will be identical with radians. A formula in radians can't be less neat. – J.G. Feb 17 at 21:40

The matrices are the same for degrees and radians. The key difference is that for $$\sin{(\theta)}$$ or another trigonometric function to be correctly evaluated in C++ you must ensure that the correct unit is used for the input value of the math function. In C++ the input values must be radians.
Well if your trigonometric operators are for degrees and not radians, you can just convert it easily: $$1° = \frac{2\pi}{360} rad$$. Your operator $$sin(x)$$ becomes $$sin(\frac{x}{\frac{2\pi }{360}})$$. Same goes for other trigonometric operators.
• $\frac{\pi}{180}$ radians – Peter Foreman Feb 17 at 21:10
• @PeterForeman : $\frac{2 \pi}{360} = \frac{\pi}{360}$, no? – PackSciences Feb 17 at 21:12