Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript Math.atan( Math.tan() ) useless?

On windows 7, look at the file

c:\windows\winsxs...\weather.js

There is a function computeSunRiseSunSet(Latitude, Longitude, TimeZone, Year, Month, Day).

They don't cite the source of the algorithm.

One line of code is

var C2=RD*(Math.atan(Math.tan(L0+C)) - Math.atan(.9175*Math.tan(L0+C))-C);

Why is there Math.atan( Math.tan( L0+C )) ?

Is it the same as ( L0+C ) or there are corner cases ?

like image 287
Massimo Avatar asked Jul 22 '26 09:07

Massimo


1 Answers

atan(tan(x)) is a periodic "sawtooth" function:

for -pi/2 < x < pi/2,   atan(tan(x)) = x
for  pi/2 < x < 3pi/2,  atan(tan(x)) = x - pi
for 3pi/2 < x < 5pi/2,  atan(tan(x)) = x - 2pi
...

You can plot it and see other details about it on Wolfram Alpha.

like image 173
Joni Avatar answered Jul 23 '26 21:07

Joni