How do i make Math.Cos to use degrees instead of radians?
if angle is 90° :
cos(90)=0 << with degrees... this one is correct
90°/57.2957795 = 1.5708 radians
Math.Cos(90) = -0.44807361612917 wrong
Math.Cos(1.5708) = -3.58659263231679E-10 wrong
Math.Cos problem
Started by chemart, Dec 26 2007 03:41 AM
3 replies to this topic
#1
Posted 26 December 2007 - 03:41 AM
|
|
|
#2
Posted 26 December 2007 - 01:29 PM
chemart said:
How do i make Math.Cos to use degrees instead of radians?
if angle is 90° :
cos(90)=0 << with degrees... this one is correct
90°/57.2957795 = 1.5708 radians
Math.Cos(90) = -0.44807361612917 wrong
Math.Cos(1.5708) = -3.58659263231679E-10 wrong
if angle is 90° :
cos(90)=0 << with degrees... this one is correct
90°/57.2957795 = 1.5708 radians
Math.Cos(90) = -0.44807361612917 wrong
Math.Cos(1.5708) = -3.58659263231679E-10 wrong
All computer languages that do trig do so with radian measure for the angles. You just need a simple formula to convert degrees to radians first. If you have x in degrees, then pi * x / 180 will be the right value for Math.Cos() (I forget if C# has a known constant for pi but 3.14159265358979 will do just fine).
By the way, the reason Math.Cos(1.5708) is not exactly zero is due to floating point roundoff problems + the fact that 1.5708 is not exactly pi / 2. Do not expect exact answers from a system that tries to represent infinitely many real numbers with only a finite number of items -- not gonna happen.
#3
Posted 08 January 2008 - 02:47 AM
#4
Posted 16 January 2008 - 01:46 AM
just have the right logic and do the tricks...


Sign In
Create Account

Back to top









