source: Sophya/trunk/SophyaExt/XephemAstroLib/sun.c@ 3023

Last change on this file since 3023 was 2818, checked in by cmv, 20 years ago

Update de Xephem 3.7 cmv 21/08/2005

File size: 1.4 KB
Line 
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 */
17void
18sunpos (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 */
44static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sun.c,v $ $Date: 2005-08-21 10:02:39 $ $Revision: 1.5 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.