So, I’m making a thing that rotates the camera around an object, and I need to get the sine and cosine of an angle (degrees).
How do I do that in C#?
Watch out:
Note that Mathf.Sin
and Mathf.Cos
does not take angles degrees but in radians. This is common in math since that’s how sine and cosine works internally / numerically.
Unity provides two conversion factors you can use to convert degrees to radians or vice versa
// convert degree to radian
float rad = degree * Mathf.Deg2Rad;
// convert radian to degree
float deg = radian * Mathf.Rad2Deg;
Radians are define as the arc-length on the unit circle. So a full circle would be 2*PI.
360° -> 2*PI
180° -> PI
90° => PI/2
...
Nevermind, I found out, it’s
Mathf.Sin()
// And
Mathf.Cos()
But how do I SET an object’s rotation?