Calculation of the correct ascension and declination of the Sun

I follow this guide by porting it to javascript: http://www.saao.ac.za/public-info/sun-moon-stars/sun-index/how-to-calculate-altaz/

Everything gradually rose to 9. (right ascension) and 10. (declination). I cannot recreate the answers they give for them.

(9) find alpha right ascension: (a) for the cape city:

lambda = 326.186 epsilon = 23.4396 alpha = arctan (tan(lambda) x cos(epsilon)) // in same quadrant as lambda // THEIR RESULT alpha = 328.428 // MY RESULT var DEGREES = function (val) { return val / (Math.PI / 180); }; var alpha = Math.atan(Math.tan(lambda) * Math.sin(epsilon)); alpha = 0.495; alpha = DEGREES(0.495) = 28.39; 

I also tried:

 var alpha = Math.atan2(Math.tan(lambda) * Math.sin(epsilon), lambda); alpha = DEGREES(result) = 1.321; 

Even close!

And 10 (a), declination

 delta = arcsin (sin(lambda) x sin(epsilon)) // THEIR RESULT (a) delta = -12.789 // MY RESULT var result = Math.asin(Math.sin(eclipticLong) * Math.sin(obliq)); result = DEGREES(result); result = -10.966; 

As you can see, I hold on to a straw because I really have no idea. Any help would be greatly appreciated.

+4
source share
1 answer

Well, the biggest problem I see here is:

 alpha = arctan (tan(lambda) x cos(epsilon)) // in same quadrant as lambda ... var alpha = Math.atan(Math.tan(lambda) * Math.sin(epsilon)); 

You have moved from using cosine to sine in the second expression.

Now, this at first glance does not lead to the same result, so let's dig a little deeper. For clarity, I will use these functions and constants:

 var lambda = 326.186; var epsilon = 23.4396; function rad (v) { return v * Math.PI / 180 } function deg (v) { return v * 180 / Math.PI } 

Javascript math functions take a radial coordinate, so let's try:

 var result = deg(Math.atan(Math.tan(rad(lambda)) * Math.cos(rad(epsilon)))); console.log(result); // -.31.5717 

Thanks to the magic of how the degrees work, this is the same answer as 360 + -31.5717 = 328.428.

+3
source

All Articles