aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/astro/merc.c
blob: 4877ef2e10aa6140c64656961298d5ad2d3d35ed (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
82
83
84
#include "astro.h"

void
merc(void)
{
	double pturbl, pturbr;
	double lograd;
	double dele, enom, vnom, nd, sl;
	double q0, v0, t0, j0 , s0;
	double lsun, elong, ci, dlong;

	ecc = .20561421 + .00002046*capt - 0.03e-6*capt2;
	incl = 7.0028806 + .0018608*capt - 18.3e-6*capt2;
	node = 47.145944 + 1.185208*capt + .0001739*capt2;
	argp = 75.899697 + 1.555490*capt + .0002947*capt2;
	mrad = .3870986;
	anom = 102.279381 + 4.0923344364*eday + 6.7e-6*capt2;
	motion = 4.0923770233;

	q0 = 102.28  + 4.092334429*eday;
	v0 = 212.536 + 1.602126105*eday;
	t0 = -1.45  + .985604737*eday;
	j0 = 225.36 + .083086735*eday;
	s0 = 175.68 + .033455441*eday;

	q0 *= radian;
	v0 *= radian;
	t0 *= radian;
	j0 *= radian;
	s0 *= radian;

	incl *= radian;
	node *= radian;
	argp *= radian;
	anom = fmod(anom, 360.)*radian;


	enom = anom + ecc*sin(anom);
	do {
		dele = (anom - enom + ecc * sin(enom)) /
			(1. - ecc*cos(enom));
		enom += dele;
	} while(fabs(dele) > converge);
	vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),
			cos(enom/2.));
	rad = mrad*(1. - ecc*cos(enom));

	icosadd(mercfp, merccp);
	pturbl =  cosadd(2, q0, -v0);
	pturbl += cosadd(2, q0, -t0);
	pturbl += cosadd(2, q0, -j0);
	pturbl += cosadd(2, q0, -s0);

	pturbr =  cosadd(2, q0, -v0);
	pturbr += cosadd(2, q0, -t0);
	pturbr += cosadd(2, q0, -j0);

/*
 *	reduce to the ecliptic
 */

	lambda = vnom + argp + pturbl*radsec;
	nd = lambda - node;
	lambda = node + atan2(sin(nd)*cos(incl), cos(nd));

	sl = sin(incl)*sin(nd);
	beta = atan2(sl, pyth(sl));

	lograd = pturbr*2.30258509;
	rad *= 1. + lograd;

	motion *= radian*mrad*mrad/(rad*rad);
	semi = 3.34;

	lsun = 99.696678 + 0.9856473354*eday;
	lsun *= radian;
	elong = lambda - lsun;
	ci = (rad - cos(elong))/sqrt(1. + rad*rad - 2.*rad*cos(elong));
	dlong = atan2(pyth(ci), ci)/radian;
	mag = -.003 + .01815*dlong + .0001023*dlong*dlong;

	helio();
	geo();
}