1 /*
2 *+
3 *  Name:
4 *     palSupgal
5 
6 *  Purpose:
7 *     Convert from supergalactic to galactic coordinates
8 
9 *  Language:
10 *     Starlink ANSI C
11 
12 *  Type of Module:
13 *     Library routine
14 
15 *  Invocation:
16 *     void palSupgal ( double dsl, double dsb, double *dl, double *db );
17 
18 *  Arguments:
19 *     dsl = double (Given)
20 *       Supergalactic longitude.
21 *     dsb = double (Given)
22 *       Supergalactic latitude.
23 *     dl = double * (Returned)
24 *       Galactic longitude.
25 *     db = double * (Returned)
26 *       Galactic latitude.
27 
28 *  Description:
29 *     Transformation from de Vaucouleurs supergalactic coordinates
30 *     to IAU 1958 galactic coordinates
31 
32 *  Authors:
33 *     PTW: Pat Wallace (STFC)
34 *     TIMJ: Tim Jenness (JAC, Hawaii)
35 *     {enter_new_authors_here}
36 
37 *  See Also:
38 *     - de Vaucouleurs, de Vaucouleurs, & Corwin, Second Reference
39 *       Catalogue of Bright Galaxies, U. Texas, page 8.
40 *     - Systems & Applied Sciences Corp., Documentation for the
41 *       machine-readable version of the above catalogue,
42 *       Contract NAS 5-26490.
43 *
44 *    (These two references give different values for the galactic
45 *     longitude of the supergalactic origin.  Both are wrong;  the
46 *     correct value is L2=137.37.)
47 
48 *  History:
49 *     2012-02-12(TIMJ):
50 *        Initial version with documentation taken from Fortran SLA
51 *        Adapted with permission from the Fortran SLALIB library.
52 *     {enter_further_changes_here}
53 
54 *  Copyright:
55 *     Copyright (C) 1995 Rutherford Appleton Laboratory
56 *     Copyright (C) 2012 Science and Technology Facilities Council.
57 *     All Rights Reserved.
58 
59 *  Licence:
60 *     This program is free software: you can redistribute it and/or
61 *     modify it under the terms of the GNU Lesser General Public
62 *     License as published by the Free Software Foundation, either
63 *     version 3 of the License, or (at your option) any later
64 *     version.
65 *
66 *     This program is distributed in the hope that it will be useful,
67 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
68 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
69 *     GNU Lesser General Public License for more details.
70 *
71 *     You should have received a copy of the GNU Lesser General
72 *     License along with this program.  If not, see
73 *     <http://www.gnu.org/licenses/>.
74 
75 *  Bugs:
76 *     {note_any_bugs_here}
77 *-
78 */
79 
80 #include "pal.h"
81 #include "pal1sofa.h"
82 
palSupgal(double dsl,double dsb,double * dl,double * db)83 void palSupgal ( double dsl, double dsb, double *dl, double *db ) {
84 
85   double v1[3];
86   double v2[3];
87 
88 /*
89 *  System of supergalactic coordinates:
90 *
91 *    SGL   SGB        L2     B2      (deg)
92 *     -    +90      47.37  +6.32
93 *     0     0         -      0
94 *
95 *  Galactic to supergalactic rotation matrix:
96 */
97   double rmat[3][3] = {
98     { -0.735742574804,+0.677261296414,+0.000000000000 },
99     { -0.074553778365,-0.080991471307,+0.993922590400 },
100     { +0.673145302109,+0.731271165817,+0.110081262225 }
101   };
102 
103   /* Spherical to Cartesian */
104   eraS2c( dsl, dsb, v1 );
105 
106   /* Supergalactic to galactic */
107   eraTrxp( rmat, v1, v2 );
108 
109   /* Cartesian to spherical */
110   eraC2s( v2, dl, db );
111 
112   /* Express in conventional ranges */
113   *dl = eraAnp( *dl );
114   *db = eraAnpm( *db );
115 
116 }
117