cos(90) = -0.45?

Started by
6 comments, last by rgirard413 18 years, 3 months ago
As any calculator will tell you, cos(90) = 0. But for some reason, in a program I've written, it's returning -0.45! o_O Doesn't seem to matter if I use cos(), (float)cos(), cosf() etc. I tried putting it right at the beginning of the program (in case it was some weird memory corruption bug) and the same thing happens. I'm doing this on WinXP SP2, with MinGW on an AMD Sempron 2800+.
---------------------------------dofile('sig.lua')
Advertisement
remember those functions take radians not degrees, type "cos 90 radians" into google and you'll get your answer, so convert the 90 to radians and bobs'ya uncle
cos() works with radians. You need to convert degrees to radians with the formula rads = degrees * pi/180.
this is because your cos function returns the answer in radians, not degrees, if you need the degrees, then you need to do this:

y = (cos(90) * (pi/180))

this will give you the result in degrees
http://www.thedizzle.com
Ah, yes. Been so long since I did trig, heh. Thanks!
---------------------------------dofile('sig.lua')
Quote:Original post by rgirard413
this is because your cos function returns the answer in radians, not degrees, if you need the degrees, then you need to do this:

y = (cos(90) * (pi/180))

this will give you the result in degrees

it must be other way around.
y = cos(90*(pi/180))
Yeah, I figured that part out once I thought back to degrees vs radians. Thanks though.
---------------------------------dofile('sig.lua')
yea sorry about that
http://www.thedizzle.com

This topic is closed to new replies.

Advertisement