cos() , sin() functions not returning corect value
the cos() and sin() functions are not returning the corect value! when i put in a value it gives me some wacky answer like cos(180) = -0.59846006905786 when it is actually equal to -1 acording to my £6 calculator and the coalculator program on widows. HELP this is very anoying!!!
~prevail by daring to fail~
Well here is the problem summed up for you. Sin & Cos on your calculator work in Degrees. The sin and cos functions in most programming languages such as C or C++ work in Radians. Here is a link to a site which will explain the degrees to radians conversion and how it''s done: http://math.usask.ca/readin/rmoa.html</html>
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
Radians are used because it''s easier for the hardware to calculate sines and cosines using radians.
When x is in radians,
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! ...
cos(x) = 1 - x^2/2! - x^4/4! + x^6/6! - x^8/8! ...
There is no formula for sin and cos in degrees, so to do those calculations would require converting degrees to radians and then using the formula.
To convert degrees to radians, divide by 180 and multiply by pi. There are 2*pi radians in a circle.
So what are radians?
In a unit circle, if you have an angle at the center, that angle, in radians, is equal to the length of the curved line along the circumference of the circle which is contained by the angle. You can imagine that defining angles in terms of a length would have made it possible to make formulas for sin and cos in the first place.
When x is in radians,
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! ...
cos(x) = 1 - x^2/2! - x^4/4! + x^6/6! - x^8/8! ...
There is no formula for sin and cos in degrees, so to do those calculations would require converting degrees to radians and then using the formula.
To convert degrees to radians, divide by 180 and multiply by pi. There are 2*pi radians in a circle.
So what are radians?
In a unit circle, if you have an angle at the center, that angle, in radians, is equal to the length of the curved line along the circumference of the circle which is contained by the angle. You can imagine that defining angles in terms of a length would have made it possible to make formulas for sin and cos in the first place.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement