Like if I I put
I get that a = .525322 when a should be = 7.07106. This happens with all thease kinds of funtions, whats happening?Code:double a = cos(45);
Like if I I put
I get that a = .525322 when a should be = 7.07106. This happens with all thease kinds of funtions, whats happening?Code:double a = cos(45);
Why drink and drive when you can smoke and fly?
a = .525322 because the function cos takes in radians rather than degrees (which should be .707106, not 7.07106)
Those functions take radians not degrees.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
duh! of course haha, Thanks a lot for the help guys
Why drink and drive when you can smoke and fly?
oh and... so... like if I want to put cos(45°) (the degrees that you need 360 for a circle) how would I do it?
Why drink and drive when you can smoke and fly?
You could write wrapper functions that do the conversions so that when you call them, you can always do it in degrees.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
As Joshdick mentioned, write a wrapper function that converts the degree measure into radians (degree * PI/180)
e.g.
Code:double sin_d (double degrees) { return (sin(degrees * 3.1416/180)); }