javascript - Why is my program making the computer appear to do bad trigonometry? -


in code, have:

console.log(distance_along); console.log('cosine: ' + math.cos(2 * math.pi * distance_along)); var added_degrees =    (ancient_clock.cos(2 * math.pi * distance_along) * ancient_clock.earth_tilt); 

this produces output:

-0.2567721374914637 cosine: -0.04253775592822526  

with more code @ http://jonathanscorner.com/ancient-clock

what have done wrong, , how can fix it? first logged value in radians (modulo multiplier of 2π), second logged value cosine of different number. why?

my earlier post gave impression didn't know math.cos(). know math.cos() , don't know why appears producing value @ variance other people have reported cos(-0.2567721374914637) in javascript , php.

i running mint chrome.

@jonathanhayward think have conceptual problem trig and/or trig functions.

i have read question 5 times , think want:

console.log(math.cos(distance_along)); console.log('cosine: ' + math.cos(2 * math.pi + distance_along)); 

or

console.log(distance_along); console.log('cosine: ' + (math.cos(2 * math.pi) * distance_along)); 

fyi:

math.cos(2 * math.pi + distance_along) == math.cos(distance_along) // true 

Comments