So I’m trying to figure out how to do some basic trig in Unity. I know I’m a little rusty, but this is terribly confusing.
My calculator says Cos(60)*10 = 5, but when I do Mathf.Cos(60)*10, I get -9.52413.
Could somebody un-stupid me?
So I’m trying to figure out how to do some basic trig in Unity. I know I’m a little rusty, but this is terribly confusing.
My calculator says Cos(60)*10 = 5, but when I do Mathf.Cos(60)*10, I get -9.52413.
Could somebody un-stupid me?
Mathf.Cos expect the angle in radians, not degrees. To make our lives easier, Unity provides the constants Mathf.Deg2Rad and Mathf.Rad2Deg: just multiply the value by the appropriate constant to convert degrees to/from radians. In the example:
print("Cos(60) = "+Mathf.Cos(60 * Mathf.Deg2Rad));
what will print 0.5