aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/astro/helio.c
blob: cb41578639221bb8d9004958464fdb1db75447d3 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "astro.h"

void
helio(void)
{
/*
 *	uses lambda, beta, rad, motion
 *	sets alpha, delta, rp
 */

/*
 *	helio converts from ecliptic heliocentric coordinates
 *	referred to the mean equinox of date
 *	to equatorial geocentric coordinates referred to
 *	the true equator and equinox
 */

	double xmp, ymp, zmp;
	double beta2;

/*
 *	compute geocentric distance of object and
 *	compute light-time correction (i.i. planetary aberration)
 */

	xmp = rad*cos(beta)*cos(lambda);
	ymp = rad*cos(beta)*sin(lambda);
	zmp = rad*sin(beta);
	rp = sqrt((xmp+xms)*(xmp+xms) +
		(ymp+yms)*(ymp+yms) +
		(zmp+zms)*(zmp+zms));
	lmb2 = lambda - .0057756e0*rp*motion;

	xmp = rad*cos(beta)*cos(lmb2);
	ymp = rad*cos(beta)*sin(lmb2);
	zmp = rad*sin(beta);

/*
 *	compute annual parallax from the position of the sun
 */

	xmp += xms;
	ymp += yms;
	zmp += zms;
	rp = sqrt(xmp*xmp + ymp*ymp + zmp*zmp);

/*
 *	compute annual (i.e. stellar) aberration
 *	from the orbital velocity of the earth
 *	(by an incorrect method)
 */

	xmp -= xdot*rp;
	ymp -= ydot*rp;
	zmp -= zdot*rp;

/*
 *	perform the nutation and so convert from the mean
 *	equator and equinox to the true
 */

	lmb2 = atan2(ymp, xmp);
	beta2 = atan2(zmp, sqrt(xmp*xmp+ymp*ymp));
	lmb2 += phi;

/*
 *	change to equatorial coordinates
 */

	xmp = rp*cos(lmb2)*cos(beta2);
	ymp = rp*(sin(lmb2)*cos(beta2)*cos(tobliq) - sin(tobliq)*sin(beta2));
	zmp = rp*(sin(lmb2)*cos(beta2)*sin(tobliq) + cos(tobliq)*sin(beta2));

	alpha = atan2(ymp, xmp);
	delta = atan2(zmp, sqrt(xmp*xmp+ymp*ymp));

	hp = 8.794e0*radsec/rp;
	semi /= rp;
	if(rad > 0 && rad < 2.e5)
		mag += 2.17*log(rad*rp);
}