Jump to content
  • Advertisement
Sign in to follow this  
HyperHacker

cos(90) = -0.45?

This topic is 4591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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+.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
cos() works with radians. You need to convert degrees to radians with the formula rads = degrees * pi/180.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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))

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!