source: Sophya/trunk/SophyaExt/XephemAstroLib/comet.c@ 2395

Last change on this file since 2395 was 1719, checked in by cmv, 24 years ago

Adapted to version 3.5 xephem cmv 22/10/2001

File size: 2.5 KB
Line 
1#include <math.h>
2
3#include "P_.h"
4#include "astro.h"
5
6/* given a modified Julian date, mjd, and a set of heliocentric parabolic
7 * orbital elements referred to the epoch of date (mjd):
8 * ep: epoch of perihelion,
9 * inc: inclination,
10 * ap: argument of perihelion (equals the longitude of perihelion minus the
11 * longitude of ascending node)
12 * qp: perihelion distance,
13 * om: longitude of ascending node;
14 * find:
15 * lpd: heliocentric longitude,
16 * psi: heliocentric latitude,
17 * rp: distance from the sun to the planet,
18 * rho: distance from the Earth to the planet,
19 * lam: geocentric ecliptic longitude,
20 * bet: geocentric ecliptic latitude,
21 * none are corrected for light time, ie, they are the true values for
22 * the given instant.
23 *
24 * all angles are in radians, all distances in AU.
25 * mutual perturbation corrections with other solar system objects are not
26 * applied. corrections for nutation and abberation must be made by the caller.
27 * The RA and DEC calculated from the fully-corrected ecliptic coordinates are
28 * then the apparent geocentric coordinates. Further corrections can be made,
29 * if required, for atmospheric refraction and geocentric parallax.
30 */
31void
32comet (mjd, ep, inc, ap, qp, om, lpd, psi, rp, rho, lam, bet)
33double mjd;
34double ep, inc, ap, qp, om;
35double *lpd, *psi, *rp, *rho, *lam, *bet;
36{
37 double w, s, s2;
38 double l, sl, cl, y;
39 double spsi, cpsi;
40 double rd, lsn, rsn;
41 double lg, re, ll;
42 double cll, sll;
43 double nu;
44
45#define ERRLMT 0.0001
46 w = ((mjd-ep)*3.649116e-02)/(qp*sqrt(qp));
47 s = w/3;
48 for (;;) {
49 double d;
50 s2 = s*s;
51 d = (s2+3)*s-w;
52 if (fabs(d) <= ERRLMT)
53 break;
54 s = ((2*s*s2)+w)/(3*(s2+1));
55 }
56
57 nu = 2*atan(s);
58 *rp = qp*(1+s2);
59 l = nu+ap;
60 sl = sin(l);
61 cl = cos(l);
62 spsi = sl*sin(inc);
63 *psi = asin(spsi);
64 y = sl*cos(inc);
65 *lpd = atan(y/cl)+om;
66 cpsi = cos(*psi);
67 if (cl<0) *lpd += PI;
68 range (lpd, 2*PI);
69 rd = *rp * cpsi;
70 sunpos (mjd, &lsn, &rsn, 0);
71 lg = lsn+PI;
72 re = rsn;
73 ll = *lpd - lg;
74 cll = cos(ll);
75 sll = sin(ll);
76 *rho = sqrt((re * re)+(*rp * *rp)-(2*re*rd*cll));
77 if (rd<re)
78 *lam = atan((-1*rd*sll)/(re-(rd*cll)))+lg+PI;
79 else
80 *lam = atan((re*sll)/(rd-(re*cll)))+*lpd;
81 range (lam, 2*PI);
82 *bet = atan((rd*spsi*sin(*lam-*lpd))/(cpsi*re*sll));
83}
84
85/* For RCS Only -- Do Not Edit */
86static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: comet.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
Note: See TracBrowser for help on using the repository browser.