1 | #include <stdio.h>
|
---|
2 | #include <math.h>
|
---|
3 |
|
---|
4 | #include "astro.h"
|
---|
5 | #include "vsop87.h"
|
---|
6 |
|
---|
7 | /* given the modified JD, mj, return the true geocentric ecliptic longitude
|
---|
8 | * of the sun for the mean equinox of the date, *lsn, in radians, the
|
---|
9 | * sun-earth distance, *rsn, in AU, and the latitude *bsn, in radians
|
---|
10 | * (since this is always <= 1.2 arcseconds, in can be neglected by
|
---|
11 | * calling with bsn = NULL).
|
---|
12 | *
|
---|
13 | * if the APPARENT ecliptic longitude is required, correct the longitude for
|
---|
14 | * nutation to the true equinox of date and for aberration (light travel time,
|
---|
15 | * approximately -9.27e7/186000/(3600*24*365)*2*pi = -9.93e-5 radians).
|
---|
16 | */
|
---|
17 | void
|
---|
18 | sunpos (double mj, double *lsn, double *rsn, double *bsn)
|
---|
19 | {
|
---|
20 | static double last_mj = -3691, last_lsn, last_rsn, last_bsn;
|
---|
21 | double ret[6];
|
---|
22 |
|
---|
23 | if (mj == last_mj) {
|
---|
24 | *lsn = last_lsn;
|
---|
25 | *rsn = last_rsn;
|
---|
26 | if (bsn) *bsn = last_bsn;
|
---|
27 | return;
|
---|
28 | }
|
---|
29 |
|
---|
30 | vsop87(mj, SUN, 0.0, ret); /* full precision earth pos */
|
---|
31 |
|
---|
32 | *lsn = ret[0] - PI; /* revert to sun pos */
|
---|
33 | range (lsn, 2*PI); /* normalise */
|
---|
34 |
|
---|
35 | last_lsn = *lsn; /* memorise */
|
---|
36 | last_rsn = *rsn = ret[2];
|
---|
37 | last_bsn = -ret[1];
|
---|
38 | last_mj = mj;
|
---|
39 |
|
---|
40 | if (bsn) *bsn = last_bsn; /* assign only if non-NULL pointer */
|
---|
41 | }
|
---|
42 |
|
---|
43 | /* For RCS Only -- Do Not Edit */
|
---|
44 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sun.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
|
---|