summaryrefslogtreecommitdiffstats
path: root/org/madore/ephem/Test.java
diff options
context:
space:
mode:
Diffstat (limited to 'org/madore/ephem/Test.java')
-rw-r--r--org/madore/ephem/Test.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/org/madore/ephem/Test.java b/org/madore/ephem/Test.java
new file mode 100644
index 0000000..70b6663
--- /dev/null
+++ b/org/madore/ephem/Test.java
@@ -0,0 +1,44 @@
+package org.madore.ephem;
+
+import java.util.Date;
+
+public final class Test {
+
+ public static void main(String[] args) {
+ Date now = new Date();
+ long nowTime = now.getTime();
+ int nowUtcMjd = (int)(nowTime/86400000) + 40587;
+ double nowUtcSeconds = (nowTime%86400000)/1000.;
+ double nowTtJd = Time.utcToTt(nowUtcMjd, nowUtcSeconds);
+ System.out.format("UTC = %dms after Unix Epoch\nJD(TT) = %.10f\n", nowTime, nowTtJd);
+ double earthLat = VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.LAT, nowTtJd);
+ double earthLong = VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.LONG, nowTtJd);
+ double earthDist = VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.DIST, nowTtJd);
+ System.out.format("VSOP87 gives: ♁ ecliptic(J2000) lat=%.6f° long=%.6f° dist=%.6fAU\n", earthLat/Comput.degree, earthLong/Comput.degree, earthDist);
+ double delayedJd = nowTtJd - earthDist*Ephem.auSeconds/86400;
+ double sunLat = -VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.LAT, delayedJd);
+ double sunLong = Math.PI + VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.LONG, delayedJd);
+ double sunDist = VSOP87.getVal(VSOP87.Planet.EARTH, VSOP87.Variable.DIST, delayedJd);
+ System.out.format("⇒ ☉ ecliptic(J2000) lat=%.6f° long=%.6f° dist=%.6fAU\n", sunLat/Comput.degree, sunLong/Comput.degree, sunDist);
+ Frames.Vector sun0 = new Frames.Vector(sunDist*Math.cos(sunLat)*Math.cos(sunLong),
+ sunDist*Math.cos(sunLat)*Math.sin(sunLong),
+ sunDist*Math.sin(sunLat));
+ System.out.format("Check: ☉ ecliptic(J2000) lat=%.6f° long=%.6f°\n",
+ Math.atan(sun0.v[2]/Math.sqrt(sun0.v[0]*sun0.v[0]+sun0.v[1]*sun0.v[1]))/Comput.degree,
+ Math.atan2(sun0.v[1], sun0.v[0])/Comput.degree);
+ Frames.Vector sun;
+ sun = Frames.Rotation.rotx(-Precession.epsilon0*Comput.arcsecond).apply(sun0);
+ System.out.format("☉ equatorial(J2000) lat=%.6f° long=%.6f°\n",
+ Math.atan(sun.v[2]/Math.sqrt(sun.v[0]*sun.v[0]+sun.v[1]*sun.v[1]))/Comput.degree,
+ Math.atan2(sun.v[1], sun.v[0])/Comput.degree);
+ sun = Precession.matrix(Ephem.fromJd(nowTtJd)).apply(sun0);
+ System.out.format("☉ equatorial(mean) lat=%.6f° long=%.6f°\n",
+ Math.atan(sun.v[2]/Math.sqrt(sun.v[0]*sun.v[0]+sun.v[1]*sun.v[1]))/Comput.degree,
+ Math.atan2(sun.v[1], sun.v[0])/Comput.degree);
+ sun = Nutation.matrix(Ephem.fromJd(nowTtJd)).apply(sun);
+ System.out.format("☉ equatorial(true) lat=%.6f° long=%.6f°\n",
+ Math.atan(sun.v[2]/Math.sqrt(sun.v[0]*sun.v[0]+sun.v[1]*sun.v[1]))/Comput.degree,
+ Math.atan2(sun.v[1], sun.v[0])/Comput.degree);
+ }
+
+}