1 /* recrad.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      RECRAD ( Rectangular coordinates to RA and DEC ) */
recrad_(doublereal * rectan,doublereal * range,doublereal * ra,doublereal * dec)9 /* Subroutine */ int recrad_(doublereal *rectan, doublereal *range,
10 	doublereal *ra, doublereal *dec)
11 {
12     extern doublereal twopi_(void);
13     extern /* Subroutine */ int reclat_(doublereal *, doublereal *,
14 	    doublereal *, doublereal *);
15 
16 /* $ Abstract */
17 
18 /*     Convert rectangular coordinates to range, right ascension, */
19 /*     and declination. */
20 
21 /* $ Disclaimer */
22 
23 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
24 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
25 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
26 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
27 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
28 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
29 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
30 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
31 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
32 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
33 
34 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
35 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
36 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
37 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
38 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
39 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
40 
41 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
42 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
43 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
44 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
45 
46 /* $ Required_Reading */
47 
48 /*     None. */
49 
50 /* $ Keywords */
51 
52 /*     CONVERSION,  COORDINATES */
53 
54 /* $ Declarations */
55 /* $ Brief_I/O */
56 
57 /*     VARIABLE  I/O  DESCRIPTION */
58 /*     --------  ---  -------------------------------------------------- */
59 /*     RECTAN     I   Rectangular coordinates of a point. */
60 /*     RANGE      O   Distance of the point from the origin. */
61 /*     RA         O   Right ascension in radians. */
62 /*     DEC        O   Declination in radians. */
63 
64 /* $ Detailed_Input */
65 
66 /*     RECTAN     The rectangular coordinates of a point. */
67 
68 /* $ Detailed_Output */
69 
70 /*     RANGE      is the distance of the point from the origin. */
71 
72 /*                The units associated with RANGE are those */
73 /*                associated with the input RECTAN. */
74 
75 
76 /*     RA         is the right ascension of RECTAN.  This is the angular */
77 /*                distance measured toward the east from the prime */
78 /*                meridian to the meridian containing the input point. */
79 /*                The direction of increasing right ascension is from */
80 /*                the +X axis towards the +Y axis. */
81 
82 /*                RA is output in radians.  The range of RA is [0, 2*pi]. */
83 
84 
85 /*     DEC        is the declination of RECTAN.  This is the angle from */
86 /*                the XY plane of the ray from the origin through the */
87 /*                point. */
88 
89 /*                DEC is output in radians.  The range of DEC is */
90 /*                [-pi/2, pi/2]. */
91 
92 /* $ Parameters */
93 
94 /*     None. */
95 
96 /* $ Exceptions */
97 
98 /*     Error free. */
99 
100 /*     1) If the X and Y components of RECTAN are both zero, the */
101 /*        right ascension is set to zero. */
102 
103 /*     2) If RECTAN is the zero vector, right ascension and declination */
104 /*        are both set to zero. */
105 
106 /* $ Files */
107 
108 /*     None. */
109 
110 /* $ Particulars */
111 
112 /*     This routine returns the range, right ascension, and declination */
113 /*     of a point specified in rectangular coordinates. */
114 
115 /*     The output is defined by a distance from a central reference */
116 /*     point, an angle from a reference meridian, and an angle above */
117 /*     the equator of a sphere centered at the central reference */
118 /*     point. */
119 
120 /* $ Examples */
121 
122 /*     The following code fragment converts right ascension and */
123 /*     declination from the B1950 reference frame to the J2000 frame. */
124 
125 /*        C */
126 /*        C     Convert RA and DEC to a 3-vector expressed in */
127 /*        C     the B1950 frame. */
128 /*        C */
129 /*              CALL RADREC ( 1.D0, RA, DEC, V1950 ) */
130 /*        C */
131 /*        C     We use the SPICELIB routine PXFORM to obtain the */
132 /*        C     transformation  matrix for converting vectors between */
133 /*        C     the B1950 and J2000 reference frames.  Since */
134 /*        C     both frames are inertial, the input time value we */
135 /*        C     supply to PXFORM is arbitrary.  We choose zero */
136 /*        C     seconds past the J2000 epoch. */
137 /*        C */
138 /*              CALL PXFORM ( 'B1950', 'J2000', 0.D0, MTRANS ) */
139 /*        C */
140 /*        C     Transform the vector to the J2000 frame. */
141 /*        C */
142 /*              CALL MXV ( MTRANS, V1950, V2000 ) */
143 /*        C */
144 /*        C     Find the RA and DEC of the J2000-relative vector. */
145 /*        C */
146 /*              CALL RECRAD ( V2000, R, RA, DEC ) */
147 
148 
149 /* $ Restrictions */
150 
151 /*     None. */
152 
153 /* $ Author_and_Institution */
154 
155 /*     C.H. Acton      (JPL) */
156 /*     N.J. Bachman    (JPL) */
157 /*     H.A. Neilan     (JPL) */
158 
159 /* $ Literature_References */
160 
161 /*     None. */
162 
163 /* $ Version */
164 
165 /* -    SPICELIB Version 1.0.2, 30-JUL-2003 (NJB) (CHA) */
166 
167 /*        Various header changes were made to improve clarity.  Some */
168 /*        minor header corrections were made. */
169 
170 /* -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
171 
172 /*        Comment section for permuted index source lines was added */
173 /*        following the header. */
174 
175 /* -    SPICELIB Version 1.0.0, 31-JAN-1990 (HAN) */
176 
177 /* -& */
178 /* $ Index_Entries */
179 
180 /*     rectangular coordinates to ra and dec */
181 /*     rectangular to right_ascension and declination */
182 
183 /* -& */
184 
185 /*     SPICELIB functions */
186 
187 
188 /*     Call the subroutine RECLAT to convert the rectangular coordinates */
189 /*     into latitudinal coordinates.  In RECLAT, the longitude ( which */
190 /*     is returned to this subroutine as RA ) ranges from - pi to pi */
191 /*     radians.   Because the right ascension ranges from zero to */
192 /*     two pi radians, whenever RA is negative two pi must be added to */
193 /*     it. */
194 
195     reclat_(rectan, range, ra, dec);
196     if (*ra < 0.) {
197 	*ra += twopi_();
198     }
199     return 0;
200 } /* recrad_ */
201 
202