forked from brandon-rhodes/pyephem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallax.c
42 lines (35 loc) · 1.34 KB
/
parallax.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <math.h>
#include "astro.h"
/* given true ha and dec, tha and tdec, the geographical latitude, phi, the
* height above sea-level (as a fraction of the earths radius, 6378.16km),
* ht, and the geocentric distance rho in Earth radii(!), find the apparent
* ha and dec, aha and adec allowing for parallax.
* all angles in radians. ehp is the angle subtended at the body by the
* earth's equator.
*/
void
ta_par (double tha, double tdec, double phi, double ht, double *rho,
double *aha, double *adec)
{
static double last_phi = 1000.0, last_ht = -1000.0, xobs, zobs;
double x, y, z; /* obj cartesian coord, in Earth radii */
/* avoid calcs involving the same phi and ht */
if (phi != last_phi || ht != last_ht) {
double cphi, sphi, robs, e2 = (2 - 1/298.257)/298.257;
cphi = cos(phi);
sphi = sin(phi);
robs = 1/sqrt(1 - e2 * sphi * sphi);
/* observer coordinates: x to meridian, y east, z north */
xobs = (robs + ht) * cphi;
zobs = (robs*(1-e2) + ht) * sphi;
last_phi = phi;
last_ht = ht;
}
sphcart(-tha, tdec, *rho, &x, &y, &z);
cartsph(x - xobs, y, z - zobs, aha, adec, rho);
*aha *= -1;
range (aha, 2*PI);
}
/* For RCS Only -- Do Not Edit */
static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: parallax.c,v $ $Date: 2003/03/20 08:51:37 $ $Revision: 1.3 $ $Name: $"};