3D Vector Rotation Matrix with Radians

1.3k Views Asked by At

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?

2

There are 2 best solutions below

1
On BEST ANSWER

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.

5
On

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.