-
Notifications
You must be signed in to change notification settings - Fork 12
/
palPlantu.c
189 lines (158 loc) · 5.99 KB
/
palPlantu.c
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
*+
* Name:
* palPlantu
* Purpose:
* Topocentric RA,Dec of a Solar-System object from universal elements
* Language:
* Starlink ANSI C
* Type of Module:
* Library routine
* Invocation:
* void palPlantu ( double date, double elong, double phi, const double u[13],
* double *ra, double *dec, double *r, int *jstat ) {
* Description:
* Topocentric apparent RA,Dec of a Solar-System object whose
* heliocentric universal elements are known.
* Arguments:
* date = double (Given)
* TT MJD of observation (JD-2400000.5)
* elong = double (Given)
* Observer's east longitude (radians)
* phi = double (Given)
* Observer's geodetic latitude (radians)
* u = const double [13] (Given)
* Universal orbital elements
* - (0) combined mass (M+m)
* - (1) total energy of the orbit (alpha)
* - (2) reference (osculating) epoch (t0)
* - (3-5) position at reference epoch (r0)
* - (6-8) velocity at reference epoch (v0)
* - (9) heliocentric distance at reference epoch
* - (10) r0.v0
* - (11) date (t)
* - (12) universal eccentric anomaly (psi) of date, approx
* ra = double * (Returned)
* Topocentric apparent RA (radians)
* dec = double * (Returned)
* Topocentric apparent Dec (radians)
* r = double * (Returned)
* Distance from observer (AU)
* jstat = int * (Returned)
* status: 0 = OK
* - -1 = radius vector zero
* - -2 = failed to converge
* Authors:
* PTW: Pat Wallace (STFC)
* TIMJ: Tim Jenness (JAC, Hawaii)
* {enter_new_authors_here}
* Notes:
* - DATE is the instant for which the prediction is required. It is
* in the TT timescale (formerly Ephemeris Time, ET) and is a
* Modified Julian Date (JD-2400000.5).
* - The longitude and latitude allow correction for geocentric
* parallax. This is usually a small effect, but can become
* important for near-Earth asteroids. Geocentric positions can be
* generated by appropriate use of routines palEpv (or palEvp) and
* palUe2pv.
* - The "universal" elements are those which define the orbit for the
* purposes of the method of universal variables (see reference 2).
* They consist of the combined mass of the two bodies, an epoch,
* and the position and velocity vectors (arbitrary reference frame)
* at that epoch. The parameter set used here includes also various
* quantities that can, in fact, be derived from the other
* information. This approach is taken to avoiding unnecessary
* computation and loss of accuracy. The supplementary quantities
* are (i) alpha, which is proportional to the total energy of the
* orbit, (ii) the heliocentric distance at epoch, (iii) the
* outwards component of the velocity at the given epoch, (iv) an
* estimate of psi, the "universal eccentric anomaly" at a given
* date and (v) that date.
* - The universal elements are with respect to the J2000 equator and
* equinox.
* See Also:
* - Sterne, Theodore E., "An Introduction to Celestial Mechanics",
* Interscience Publishers Inc., 1960. Section 6.7, p199.
* - Everhart, E. & Pitkin, E.T., Am.J.Phys. 51, 712, 1983.
* History:
* 2012-03-12 (TIMJ):
* Initial version direct conversion of SLA/F.
* Adapted with permission from the Fortran SLALIB library.
* {enter_further_changes_here}
* Copyright:
* Copyright (C) 2005 Patrick T. Wallace
* Copyright (C) 2012 Science and Technology Facilities Council.
* All Rights Reserved.
* Licence:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
* Bugs:
* {note_any_bugs_here}
*-
*/
#include <math.h>
#include "pal.h"
#include "palmac.h"
#include "pal1sofa.h"
void palPlantu ( double date, double elong, double phi, const double u[13],
double *ra, double *dec, double *r, int *jstat ) {
int i;
double dvb[3], dpb[3], vsg[6], vsp[6], v[6], rmat[3][3],
vgp[6], stl, vgo[6], dx, dy, dz, d, tl;
double ucp[13];
/* To retain the stated const API and conform to the documentation
we must copy the contents of the u array as palUe2pv updates
the final two elements */
for (i=0;i<13;i++) {
ucp[i] = u[i];
}
/* Sun to geocentre (J2000, velocity in AU/s) */
palEpv( date, vsg, &(vsg[3]), dpb, dvb );
for (i=3; i < 6; i++) {
vsg[i] /= PAL__SPD;
}
/* Sun to planet (J2000) */
palUe2pv( date, ucp, vsp, jstat );
/* Geocentre to planet (J2000) */
for (i=0; i<6; i++) {
v[i] = vsp[i] - vsg[i];
}
/* Precession and nutation to date */
palPrenut( 2000.0, date, rmat );
eraRxp(rmat, v, vgp);
eraRxp( rmat, &(v[3]), &(vgp[3]) );
/* Geocentre to observer (date) */
stl = palGmst( date - palDt( palEpj(date) ) / PAL__SPD ) + elong;
palPvobs( phi, 0.0, stl, vgo );
/* Observer to planet (date) */
for (i=0; i<6; i++) {
v[i] = vgp[i] - vgo[i];
}
/* Geometric distance (AU) */
dx = v[0];
dy = v[1];
dz = v[2];
d = sqrt( dx*dx + dy*dy + dz*dz );
/* Light time (sec) */
tl = PAL__CR * d;
/* Correct position for planetary aberration */
for (i=0; i<3; i++) {
v[i] -= tl * v[i+3];
}
/* To RA,Dec */
eraC2s( v, ra, dec );
*ra = eraAnp( *ra );
*r = d;
}