source: trunk/FACT++/pal/palPlanet.c

Last change on this file was 18347, checked in by tbretz, 9 years ago
File size: 2.8 KB
Line 
1/*
2*+
3* Name:
4* palPlanet
5
6* Purpose:
7* Approximate heliocentric position and velocity of major planet
8
9* Language:
10* Starlink ANSI C
11
12* Type of Module:
13* Library routine
14
15* Invocation:
16* void palPlanet ( double date, int np, double pv[6], int *j );
17
18* Arguments:
19* date = double (Given)
20* TDB Modified Julian Date (JD-2400000.5).
21* np = int (Given)
22* planet (1=Mercury, 2=Venus, 3=EMB, 4=Mars,
23* 5=Jupiter, 6=Saturn, 7=Uranus, 8=Neptune)
24* pv = double [6] (Returned)
25* heliocentric x,y,z,xdot,ydot,zdot, J2000, equatorial triad
26* in units AU and AU/s.
27* j = int * (Returned)
28* - -2 = solution didn't converge.
29* - -1 = illegal np (1-8)
30* - 0 = OK
31* - +1 = warning: year outside 1000-3000
32
33* Description:
34* Calculates the approximate heliocentric position and velocity of
35* the specified major planet.
36
37* Authors:
38* TIMJ: Tim Jenness (JAC, Hawaii)
39* {enter_new_authors_here}
40
41* Notes:
42* - See SOFA/ERFA eraPlan94 for details
43* - Note that Pluto is supported in SLA/F but not in this routine
44* - Status -2 is equivalent to eraPlan94 status +2.
45* - Note that velocity units here match the SLA/F documentation.
46
47* History:
48* 2012-03-07 (TIMJ):
49* Initial version
50* Adapted with permission from the Fortran SLALIB library.
51* {enter_further_changes_here}
52
53* Copyright:
54* Copyright (C) 2012 Science and Technology Facilities Council.
55* All Rights Reserved.
56
57* Licence:
58* This program is free software; you can redistribute it and/or
59* modify it under the terms of the GNU General Public License as
60* published by the Free Software Foundation; either version 3 of
61* the License, or (at your option) any later version.
62*
63* This program is distributed in the hope that it will be
64* useful, but WITHOUT ANY WARRANTY; without even the implied
65* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
66* PURPOSE. See the GNU General Public License for more details.
67*
68* You should have received a copy of the GNU General Public License
69* along with this program; if not, write to the Free Software
70* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
71* MA 02110-1301, USA.
72
73* Bugs:
74* {note_any_bugs_here}
75*-
76*/
77
78#include "pal.h"
79#include "palmac.h"
80#include "pal1sofa.h"
81
82void palPlanet ( double date, int np, double pv[6], int *j ) {
83 double erapv[2][3];
84
85 *j = eraPlan94( PAL__MJD0, date, np, erapv );
86
87 /* Convert the outputs to the correct form and also correct AU/d
88 to AU/s */
89 pv[0] = erapv[0][0];
90 pv[1] = erapv[0][1];
91 pv[2] = erapv[0][2];
92 pv[3] = erapv[1][0] / PAL__SPD;
93 pv[4] = erapv[1][1] / PAL__SPD;
94 pv[5] = erapv[1][2] / PAL__SPD;
95
96 /* SLA compatibility for status */
97 if (*j == 2) *j = -2;
98
99}
Note: See TracBrowser for help on using the repository browser.