math.cos() incorrect

So I just spent a couple hours trying to get something to work that requires cos to work properly, then I find out by simply comparing my calculator and a couple online calcs to a print of math.cos(),
that math.cos() isn’t even correct. Example: math.cos( 45 ) = 0.52532198881773 and a proper calculator = 0.707106781187. Fuck me.

Am I doing something wrong here?

cos(45) = 0.70710678118 degrees,
cos(45) = 0.52532198881 radians.

GMod’s math fuction is giving you the calculation in radians. The conversion is pretty straightforward luckily: again!.gif


This will convert your radians calculation to degrees.

To add: You don’t even need the formula for converting from degrees to radians, as Lua has a function to do that for you (but it’s still useful to know).


Thanks both of you.

Important correction…
cos(45 degrees) = 0.70710678118,
cos(45 radians) = 0.52532198881.

and as Bo98 said:
Not the other way around.