~ubuntu-branches/ubuntu/raring/starlink-pal/raring-proposed

« back to all changes in this revision

Viewing changes to palPlanet.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2012-03-28 11:00:00 UTC
  • Revision ID: package-import@ubuntu.com-20120328110000-9iw40yuy69wuk7po
Tags: upstream-0.1.0
ImportĀ upstreamĀ versionĀ 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 iauPlan94 for details
 
43
*     - Note that Pluto is supported in SLA/F but not in this routine
 
44
*     - Status -2 is equivalent to iauPlan94 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
*     {enter_further_changes_here}
 
51
 
 
52
*  Copyright:
 
53
*     Copyright (C) 2012 Science and Technology Facilities Council.
 
54
*     All Rights Reserved.
 
55
 
 
56
*  Licence:
 
57
*     This program is free software; you can redistribute it and/or
 
58
*     modify it under the terms of the GNU General Public License as
 
59
*     published by the Free Software Foundation; either version 3 of
 
60
*     the License, or (at your option) any later version.
 
61
*
 
62
*     This program is distributed in the hope that it will be
 
63
*     useful, but WITHOUT ANY WARRANTY; without even the implied
 
64
*     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
65
*     PURPOSE. See the GNU General Public License for more details.
 
66
*
 
67
*     You should have received a copy of the GNU General Public License
 
68
*     along with this program; if not, write to the Free Software
 
69
*     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
70
*     MA 02110-1301, USA.
 
71
 
 
72
*  Bugs:
 
73
*     {note_any_bugs_here}
 
74
*-
 
75
*/
 
76
 
 
77
#include "pal.h"
 
78
#include "palmac.h"
 
79
#include "sofa.h"
 
80
 
 
81
void palPlanet ( double date, int np, double pv[6], int *j ) {
 
82
  double iaupv[2][3];
 
83
 
 
84
  *j = iauPlan94( PAL__MJD0, date, np, iaupv );
 
85
 
 
86
  /* Convert the outputs to the correct form and also correct AU/d
 
87
     to AU/s */
 
88
  pv[0] = iaupv[0][0];
 
89
  pv[1] = iaupv[0][1];
 
90
  pv[2] = iaupv[0][2];
 
91
  pv[3] = iaupv[1][0] / PAL__SPD;
 
92
  pv[4] = iaupv[1][1] / PAL__SPD;
 
93
  pv[5] = iaupv[1][2] / PAL__SPD;
 
94
 
 
95
  /* SLA compatibility for status */
 
96
  if (*j == 2) *j = -2;
 
97
 
 
98
}