aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/astro/geo.c
diff options
context:
space:
mode:
authorwkj <devnull@localhost>2004-04-21 02:16:43 +0000
committerwkj <devnull@localhost>2004-04-21 02:16:43 +0000
commitcd5bae7871bc0f0bc68b4d2a84703929a7a3c9d1 (patch)
tree336db54785d2b77113a6e570574be715c7eb7d1d /src/cmd/astro/geo.c
parent95f57b01e21feb457e79eaf52d593422c318024f (diff)
downloadplan9port-cd5bae7871bc0f0bc68b4d2a84703929a7a3c9d1.tar.gz
plan9port-cd5bae7871bc0f0bc68b4d2a84703929a7a3c9d1.tar.bz2
plan9port-cd5bae7871bc0f0bc68b4d2a84703929a7a3c9d1.zip
Astro with some minor changes to placate Unix.
Diffstat (limited to 'src/cmd/astro/geo.c')
-rw-r--r--src/cmd/astro/geo.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/cmd/astro/geo.c b/src/cmd/astro/geo.c
new file mode 100644
index 00000000..de562210
--- /dev/null
+++ b/src/cmd/astro/geo.c
@@ -0,0 +1,60 @@
+#include "astro.h"
+
+void
+geo(void)
+{
+
+/*
+ * uses alpha, delta, rp
+ */
+
+/*
+ * sets ra, decl, lha, decl2, az, el
+ */
+
+/*
+ * geo converts geocentric equatorial coordinates
+ * to topocentric equatorial and topocentric horizon
+ * coordinates.
+ * All are (usually) referred to the true equator.
+ */
+
+ double sel, saz, caz;
+ double f;
+ double sa, ca, sd;
+
+/*
+ * convert to local hour angle and declination
+ */
+
+ lha = gst - alpha - wlong;
+ decl = delta;
+
+/*
+ * compute diurnal parallax (requires geocentric latitude)
+ */
+
+ sa = cos(decl)*sin(lha);
+ ca = cos(decl)*cos(lha) - erad*cos(glat)*sin(hp);
+ sd = sin(decl) - erad*sin(glat)*sin(hp);
+
+ lha = atan2(sa, ca);
+ decl2 = atan2(sd, sqrt(sa*sa+ca*ca));
+ f = sqrt(sa*sa+ca*ca+sd*sd);
+ semi2 = semi/f;
+ ra = gst - lha - wlong;
+ ra = pinorm(ra);
+
+/*
+ * convert to horizon coordinates
+ */
+
+ sel = sin(nlat)*sin(decl2) + cos(nlat)*cos(decl2)*cos(lha);
+ el = atan2(sel, pyth(sel));
+ saz = sin(lha)*cos(decl2);
+ caz = cos(nlat)*sin(decl2) - sin(nlat)*cos(decl2)*cos(lha);
+ az = pi + atan2(saz, -caz);
+
+ az /= radian;
+ el /= radian;
+}