Fabiz / MeeusJs

MeeusJs is an implementation of some algorithms of the Book 'Astronomical Algorithms of Jean Meeus' in Javascript.
MIT License
84 stars 16 forks source link

altitude #15

Open gatelli opened 3 years ago

gatelli commented 3 years ago

I found the calculation doesn't take into account the altitude, although the parameter h is included in coordinates. It doesn't modify anything for the results, and it should. Can you confirm that ? Thx

jumpjack commented 1 year ago

This code shows a (tiny) difference in results:

a=new Date("2023-03-01 12:00:00Z");
jdo = new A.JulianDay(a)
coord1 = A.EclCoord.fromWgs84(42,12,0);
coord2 = A.EclCoord.fromWgs84(42,12,10000);
res1=A.Solar.topocentricPosition(jdo, coord1, true); // true/false = with/without refraction
res2=A.Solar.topocentricPosition(jdo, coord2, true)

console.log("Azimuth:")
console.log("Rad:" , res1.hz.az +Math.PI , res2.hz.az+Math.PI, (((res2.hz.az-res1.hz.az)/res1.hz.az)*100).toFixed(8) + "%");
console.log("Deg:" , res1.hz.az*180/Math.PI + 180, res2.hz.az*180/Math.PI + 180, (((res2.hz.az-res1.hz.az)/res1.hz.az)*100).toFixed(8) + "%");

console.log("Elevation:")
console.log("Rad:" , res1.hz.alt, res2.hz.alt, (((res2.hz.alt-res1.hz.alt)/res1.hz.alt)*100).toFixed(8) + "%");
console.log("Deg:" , res1.hz.alt*180/Math.PI, res2.hz.alt*180/Math.PI, (((res2.hz.alt-res1.hz.alt)/res1.hz.alt)*100).toFixed(8) + "%");

Output (alt = 0, alt = 10000, difference):

Results from NASA Horizons (azimuth, elevation):

Altitude = 0:

Altitude = 10000:

Code output manually reordered as Horizons:

Altitude = 0

Altitude = 10000