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        | = |x'|
|y cos θ − z sin θ| = |y'|
|y sin θ + z cos θ| = |z'|
|z sin θ + x cos θ| = |x'|
|        y        | = |y'|
|z cos θ - x sin θ| = |z'|
|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?

  • $\begingroup$ The value of $\sin{(\theta)}$ is the same no matter whether we use 'angles' or radians - What do you mean? $\endgroup$ – Peter Foreman Feb 17 at 21:08
  • $\begingroup$ @PeterForeman Degrees! Why do I keep on thinking of degrees as angles? $\endgroup$ – Brendon Shaw Feb 17 at 21:13
  • $\begingroup$ @PeterForeman I am getting my terms mixed up right now. Sorry about that. $\endgroup$ – Brendon Shaw Feb 17 at 21:15
  • $\begingroup$ 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. $\endgroup$ – 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.

  • $\begingroup$ Of course it does! That's what it was doing! $\endgroup$ – Brendon Shaw Feb 17 at 21:23

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.

  • $\begingroup$ $\frac{\pi}{180}$ radians $\endgroup$ – Peter Foreman Feb 17 at 21:10
  • $\begingroup$ @PeterForeman : $\frac{2 \pi}{360} = \frac{\pi}{360}$, no? $\endgroup$ – PackSciences Feb 17 at 21:12
  • $\begingroup$ I just meant that you can simplify the fraction by cancelling the GCD of 2 from the top and bottom $\endgroup$ – Peter Foreman Feb 17 at 21:13
  • $\begingroup$ @PackSciences I have already realized you can do that. I want to learn what the matrices would be for radians instead of degrees. $\endgroup$ – Brendon Shaw Feb 17 at 21:16
  • $\begingroup$ I am sorry, I don't understand. My answer gives you the replacement to do in your matrix. $\endgroup$ – PackSciences Feb 17 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.