1 /*
2 *+
3 *  Name:
4 *     palEqecl
5 
6 *  Purpose:
7 *     Transform from J2000.0 equatorial coordinates to ecliptic coordinates
8 
9 *  Language:
10 *     Starlink ANSI C
11 
12 *  Type of Module:
13 *     Library routine
14 
15 *  Invocation:
16 *     void palEqecl( double dr, double dd, double date,
17 *                    double *dl, double *db);
18 
19 *  Arguments:
20 *     dr = double (Given)
21 *        J2000.0 mean RA (radians)
22 *     dd = double (Given)
23 *        J2000.0 mean Dec (Radians)
24 *     date = double (Given)
25 *        TT as Modified Julian Date (JD-2400000.5). The difference
26 *        between TT and TDB is of the order of a millisecond or two
27 *        (i.e. about 0.02 arc-seconds).
28 *     dl = double * (Returned)
29 *        Ecliptic longitude (mean of date, IAU 1980 theory, radians)
30 *     db = double * (Returned)
31 *        Ecliptic latitude (mean of date, IAU 1980 theory, radians)
32 
33 *  Description:
34 *     Transform from J2000.0 equatorial coordinates to ecliptic coordinates.
35 
36 *  Authors:
37 *     PTW: Patrick T. Wallace
38 *     TIMJ: Tim Jenness (JAC, Hawaii)
39 *     {enter_new_authors_here}
40 
41 *  History:
42 *     2012-03-02 (TIMJ):
43 *        Initial version
44 *        Adapted with permission from the Fortran SLALIB library.
45 *     {enter_further_changes_here}
46 
47 *  Copyright:
48 *     Copyright (C) 1995 Rutherford Appleton Laboratory
49 *     Copyright (C) 2012 Science and Technology Facilities Council.
50 *     All Rights Reserved.
51 
52 *  Licence:
53 *     This program is free software; you can redistribute it and/or
54 *     modify it under the terms of the GNU General Public License as
55 *     published by the Free Software Foundation; either version 3 of
56 *     the License, or (at your option) any later version.
57 *
58 *     This program is distributed in the hope that it will be
59 *     useful, but WITHOUT ANY WARRANTY; without even the implied
60 *     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
61 *     PURPOSE. See the GNU General Public License for more details.
62 *
63 *     You should have received a copy of the GNU General Public License
64 *     along with this program; if not, write to the Free Software
65 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
66 *     MA 02110-1301, USA.
67 
68 *  Bugs:
69 *     {note_any_bugs_here}
70 *-
71 */
72 
73 #include "pal.h"
74 #include "pal1sofa.h"
75 
palEqecl(double dr,double dd,double date,double * dl,double * db)76 void palEqecl ( double dr, double dd, double date, double *dl, double *db ) {
77   double v1[3], v2[3];
78   double rmat[3][3];
79 
80   /* Spherical to Cartesian */
81   eraS2c( dr, dd, v1 );
82 
83   /* Mean J2000 to mean of date */
84   palPrec( 2000.0, palEpj(date), rmat );
85   eraRxp( rmat, v1, v2 );
86 
87   /* Equatorial to ecliptic */
88   palEcmat( date, rmat );
89   eraRxp( rmat, v2, v1 );
90 
91   /* Cartesian to spherical */
92   eraC2s( v1, dl, db );
93 
94   /* Express in conventional range */
95   *dl = eraAnp( *dl );
96   *db = palDrange( *db );
97 }
98