Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Stereographic.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton, Alicia Sintes Olives
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*-----------------------------------------------------------------------
21 *
22 * File Name: Stereographic.c
23 *
24 * Authors: Sintes, A.M.,
25 *
26 *
27 * History: Created by Sintes May 15, 2001
28 * Modified...
29 *
30 *-----------------------------------------------------------------------
31 *
32 * NAME
33 * Stereographic.c
34 *
35 * SYNOPSIS
36 *
37 * DESCRIPTION
38 *
39 * DIAGNOSTICS
40 *
41 *-----------------------------------------------------------------------
42 */
43
44/**
45 * \author Sintes, A. M.
46 * \file
47 * \ingroup LUT_h
48 * \brief Routines to perform rotations on the celestial sphere and stereographic projection.
49 *
50 * ### Description ###
51 *
52 * The function LALRotatePolarU() rotates the celestial sphere so that
53 * a given point, in the rotated coordinates, corresponds to ( \f$ \alpha = 0 \f$ , \f$ \delta = -\pi/2 \f$ ).
54 * The inputs are:
55 * <tt>*par</tt> the reference point (e.g., the center of the sky-patch) of type
56 * \c REAL8UnitPolarCoor and
57 * <tt>*in</tt> the point on the celestial sphere we want to rotate. The output is
58 * <tt>*out</tt> of type \c REAL8UnitPolarCoor containing the coordinates of the
59 * point in the rotated reference frame.
60 *
61 * The function LALInvRotatePolarU() does the inverse rotation. Given the
62 * reference point <tt>*par</tt> (e.g., the center of the sky-patch) of type
63 * \c REAL8UnitPolarCoor and a point <tt>*in</tt> in the rotated reference
64 * frame, the output <tt>*out</tt> are the coordinates of the point is the
65 * same reference system as <tt>*par</tt>. All inputs and output being
66 * of type \c REAL8UnitPolarCoor.
67 *
68 * Given a point on the celestial sphere <tt>*in</tt> of type
69 * \c REAL8UnitPolarCoor, the function LALStereoProjectPolar()
70 * returns <tt>*out</tt>,
71 * of type \c REAL8Polar2Coor, the stereographic projection of that point
72 * in polar coordinates, with the particularity that <tt>out->radius</tt> can be positive
73 * or negative. <tt>in->delta</tt>= \f$ \pi/2 \f$ is an invalid argument and an error will
74 * output.
75 *
76 * Given a point on the celestial sphere <tt>*in</tt> of type
77 * \c REAL8UnitPolarCoor, the function LALStereoProjectCart()
78 * returns <tt>*out</tt>, of type \c REAL8Cart2Coor, the stereographic projection of that point
79 * in Cartesian coordinates. <tt>in->delta</tt>= \f$ \pi/2 \f$ is an invalid argument and an error will
80 * output.
81 *
82 * Given a point on the projected plane <tt>*in</tt> , the functions
83 * LALStereoInvProjectPolar() and LALStereoInvProjectCart()
84 * provide the corresponding point on the sphere <tt>*out</tt> (corresponding to the inverse
85 * stereographic projection) of type \c REAL8UnitPolarCoor.
86 *
87 */
88
89#include <lal/LUT.h>
90
91/*
92 * The functions that make up the guts of this module
93 */
94
95/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
96
101{
102
103 REAL8 Xx, Xy, Xz;
104 REAL8 Yx, Yy, Yz;
105 REAL8 Zx, Zy, Zz;
106 REAL8 alphaN, deltaN;
107 REAL8 alphaIn, deltaIn;
108
109 REAL8 VIx, VIy, VIz;
110 REAL8 Vx, Vy, Vz;
111
112 /* --------------------------------------------- */
115
116 /* Make sure the arguments are not NULL: */
120 /* ------------------------------------------- */
121
122 alphaN = par->alpha;
123 deltaN = par->delta;
124
125 alphaIn = in->alpha;
126 deltaIn = in->delta;
127
128 /* ------------------------------------------- */
129 /* Initial vector */
130 VIx = cos( deltaIn ) * cos( alphaIn ) ;
131 VIy = cos( deltaIn ) * sin( alphaIn );
132 VIz = sin( deltaIn );
133
134 /* ------------------------------------------- */
135 /* Rotation matrix */
136 Xx = -sin( deltaN ) * cos( alphaN ) ;
137 Xy = -sin( deltaN ) * sin( alphaN );
138 Xz = cos( deltaN );
139 Yx = -sin( alphaN );
140 Yy = cos( alphaN );
141 Yz = 0.0;
142 Zx = -cos( deltaN ) * cos( alphaN );
143 Zy = -cos( deltaN ) * sin( alphaN );
144 Zz = -sin( deltaN );
145
146 /* ------------------------------------------- */
147 /* Final vector */
148
149 Vx = Xx * VIx + Xy * VIy + Xz * VIz ;
150 Vy = Yx * VIx + Yy * VIy + Yz * VIz ;
151 Vz = Zx * VIx + Zy * VIy + Zz * VIz ;
152
153 /* ------------------------------------------- */
154
155 /* output */
156
157 if ( Vx || Vy ) {
158 out->alpha = atan2( Vy, Vx );
159 } else {
160 out->alpha = 0.0;
161 }
162 out->delta = asin( Vz );
163
164 /* ------------------------------------------- */
165
167
168 /* normal exit */
169 RETURN( status );
170}
171
172
173
174
175/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
176
181{
182
183 REAL8 Xx, Xy, Xz;
184 REAL8 Yx, Yy, Yz;
185 REAL8 Zx, Zy, Zz;
186 REAL8 alphaN, deltaN;
187 REAL8 alphaIn, deltaIn;
188
189 REAL8 VIx, VIy, VIz;
190 REAL8 Vx, Vy, Vz;
191
192 /* --------------------------------------------- */
195
196 /* Make sure the arguments are not NULL: */
200 /* ------------------------------------------- */
201
202 alphaN = par->alpha;
203 deltaN = par->delta;
204
205 alphaIn = in->alpha;
206 deltaIn = in->delta;
207
208 /* ------------------------------------------- */
209 /* Initial vector */
210 VIx = cos( deltaIn ) * cos( alphaIn ) ;
211 VIy = cos( deltaIn ) * sin( alphaIn );
212 VIz = sin( deltaIn );
213
214 /* ------------------------------------------- */
215 /* Inverse Rotation matrix */
216 Xx = - cos( alphaN ) * sin( deltaN ) ;
217 Xy = - sin( alphaN );
218 Xz = - cos( alphaN ) * cos( deltaN );
219 Yx = - sin( alphaN ) * sin( deltaN );
220 Yy = cos( alphaN );
221 Yz = - sin( alphaN ) * cos( deltaN ) ;
222 Zx = cos( deltaN );
223 Zy = 0.0;
224 Zz = -sin( deltaN );
225
226 /* ------------------------------------------- */
227 /* Final vector */
228
229 Vx = Xx * VIx + Xy * VIy + Xz * VIz ;
230 Vy = Yx * VIx + Yy * VIy + Yz * VIz ;
231 Vz = Zx * VIx + Zy * VIy + Zz * VIz ;
232
233 /* ------------------------------------------- */
234
235 /* output */
236
237 if ( Vx || Vy ) {
238 out->alpha = atan2( Vy, Vx );
239 } else {
240 out->alpha = 0.0;
241 }
242 out->delta = asin( Vz );
243
244 /* ------------------------------------------- */
245
247
248 /* normal exit */
249 RETURN( status );
250}
251
252/* ------------------------------------------- */
253
254
255/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
256
258 REAL8Polar2Coor *out,
260{
261
262 REAL8 mygamma;
263 /* --------------------------------------------- */
266
267 /* Make sure the arguments are not NULL: */
270 /* Make sure delta is not pi/2: */
272 /* ------------------------------------------- */
273
274 out->alpha = in->alpha;
275 mygamma = LAL_PI_4 + 0.5 * ( in->delta );
276 out->radius = 2.0 * tan( mygamma ); /* positive or negative ! */
277 /* ------------------------------------------- */
278
280
281 /* normal exit */
282 RETURN( status );
283}
284
285
286
287
288/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
289
291 REAL8Cart2Coor *out,
293{
294
295 REAL8 mygamma;
296 REAL8 alpha, radius;
297 /* --------------------------------------------- */
300
301 /* Make sure the arguments are not NULL: */
304 /* Make sure delta is not pi/2: */
306 /* ------------------------------------------- */
307
308 alpha = in->alpha;
309 mygamma = LAL_PI_4 + 0.5 * ( in->delta );
310 radius = 2.0 * tan( mygamma ); /* positive or negative */
311
312 out->x = radius * cos( alpha );
313 out->y = radius * sin( alpha );
314 /* ------------------------------------------- */
315
317
318 /* normal exit */
319 RETURN( status );
320}
321
322
323/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
324
327 REAL8Polar2Coor *in )
328{
329
330
331 /* --------------------------------------------- */
334
335 /* Make sure the arguments are not NULL: */
338 /* ------------------------------------------- */
339
340 out->alpha = in->alpha;
341 out->delta = 2.0 * atan( 0.5 * ( in->radius ) ) - LAL_PI_2;
342
343 /* Note: since I have not ask for a positive radius input, */
344 /* delta in principle is not cofined to (-pi/2, pi/2) */
345 /* ------------------------------------------- */
346
348
349 /* normal exit */
350 RETURN( status );
351}
352
353
354
355/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
356
359 REAL8Cart2Coor *in )
360{
361
362 REAL8 x, y, radius;
363 /* --------------------------------------------- */
366
367 /* Make sure the arguments are not NULL: */
370 /* ------------------------------------------- */
371
372 x = in->x;
373 y = in->y;
374 if ( x || y ) {
375 radius = sqrt( x * x + y * y );
376
377 out->alpha = atan2( y, x );
378 out->delta = 2.0 * atan( 0.5 * ( radius ) ) - LAL_PI_2;
379 /* Note: since I have not ask for a positive radius input, */
380 /* delta in principle is not cofined to (-pi/2, pi/2) */
381
382 } else { /* x=y =0 */
383 out->alpha = 0.0;
384 out->delta = - LAL_PI_2;
385 }
386
387 /* ------------------------------------------- */
388
390
391 /* normal exit */
392 RETURN( status );
393}
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define LAL_PI_2
#define LAL_PI_4
double REAL8
void LALStereoProjectCart(LALStatus *status, REAL8Cart2Coor *out, REAL8UnitPolarCoor *in)
void LALRotatePolarU(LALStatus *status, REAL8UnitPolarCoor *out, REAL8UnitPolarCoor *in, REAL8UnitPolarCoor *par)
Definition: Stereographic.c:97
void LALStereoProjectPolar(LALStatus *status, REAL8Polar2Coor *out, REAL8UnitPolarCoor *in)
#define LUTH_MSGENULL
Definition: LUT.h:157
#define LUTH_EVAL
Definition: LUT.h:155
void LALInvRotatePolarU(LALStatus *status, REAL8UnitPolarCoor *out, REAL8UnitPolarCoor *in, REAL8UnitPolarCoor *par)
void LALStereoInvProjectPolar(LALStatus *status, REAL8UnitPolarCoor *out, REAL8Polar2Coor *in)
#define LUTH_ENULL
Definition: LUT.h:149
#define LUTH_MSGEVAL
Definition: LUT.h:163
void LALStereoInvProjectCart(LALStatus *status, REAL8UnitPolarCoor *out, REAL8Cart2Coor *in)
list y
out
double alpha
Two dimensional Cartessian coordinates.
Definition: LUT.h:315
REAL8 y
Definition: LUT.h:317
REAL8 x
Definition: LUT.h:316
Two dimensional polar coordinates.
Definition: LUT.h:321
REAL8 radius
Definition: LUT.h:323
REAL8 alpha
Definition: LUT.h:322
Polar coordinates of a unitary vector on the sphere.
Definition: LUT.h:327
REAL8 alpha
any value
Definition: LUT.h:328
REAL8 delta
In the interval [ ].
Definition: LUT.h:329