WCSLIB  5.4.1
prj.h
Go to the documentation of this file.
1 /*============================================================================
2 
3  WCSLIB 5.5 - an implementation of the FITS WCS standard.
4  Copyright (C) 1995-2015, Mark Calabretta
5 
6  This file is part of WCSLIB.
7 
8  WCSLIB is free software: you can redistribute it and/or modify it under the
9  terms of the GNU Lesser General Public License as published by the Free
10  Software Foundation, either version 3 of the License, or (at your option)
11  any later version.
12 
13  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16  more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with WCSLIB. If not, see http://www.gnu.org/licenses.
20 
21  Direct correspondence concerning WCSLIB to mark@calabretta.id.au
22 
23  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
24  http://www.atnf.csiro.au/people/Mark.Calabretta
25  $Id: prj.h,v 5.5 2015/05/05 13:16:31 mcalabre Exp $
26 *=============================================================================
27 *
28 * WCSLIB 5.5 - C routines that implement the FITS World Coordinate System
29 * (WCS) standard. Refer to the README file provided with WCSLIB for an
30 * overview of the library.
31 *
32 *
33 * Summary of the prj routines
34 * ---------------------------
35 * Routines in this suite implement the spherical map projections defined by
36 * the FITS World Coordinate System (WCS) standard, as described in
37 *
38 = "Representations of world coordinates in FITS",
39 = Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (WCS Paper I)
40 =
41 = "Representations of celestial coordinates in FITS",
42 = Calabretta, M.R., & Greisen, E.W. 2002, A&A, 395, 1077 (WCS Paper II)
43 =
44 = "Mapping on the HEALPix grid",
45 = Calabretta, M.R., & Roukema, B.F. 2007, MNRAS, 381, 865 (WCS Paper V)
46 =
47 = "Representing the 'Butterfly' Projection in FITS -- Projection Code XPH",
48 = Calabretta, M.R., & Lowe, S.R. 2013, PASA, 30, e050 (WCS Paper VI)
49 *
50 * These routines are based on the prjprm struct which contains all information
51 * needed for the computations. The struct contains some members that must be
52 * set by the user, and others that are maintained by these routines, somewhat
53 * like a C++ class but with no encapsulation.
54 *
55 * Routine prjini() is provided to initialize the prjprm struct with default
56 * values, prjfree() reclaims any memory that may have been allocated to store
57 * an error message, and prjprt() prints its contents. prjbchk() performs
58 * bounds checking on native spherical coordinates.
59 *
60 * Setup routines for each projection with names of the form ???set(), where
61 * "???" is the down-cased three-letter projection code, compute intermediate
62 * values in the prjprm struct from parameters in it that were supplied by the
63 * user. The struct always needs to be set by the projection's setup routine
64 * but that need not be called explicitly - refer to the explanation of
65 * prjprm::flag.
66 *
67 * Each map projection is implemented via separate functions for the spherical
68 * projection, ???s2x(), and deprojection, ???x2s().
69 *
70 * A set of driver routines, prjset(), prjx2s(), and prjs2x(), provides a
71 * generic interface to the specific projection routines which they invoke
72 * via pointers-to-functions stored in the prjprm struct.
73 *
74 * In summary, the routines are:
75 * - prjini() Initialization routine for the prjprm struct.
76 * - prjfree() Reclaim memory allocated for error messages.
77 * - prjprt() Print the prjprm struct.
78 * - prjbchk() Bounds checking on native coordinates.
79 *
80 * - prjset(), prjx2s(), prjs2x(): Generic driver routines
81 *
82 * - azpset(), azpx2s(), azps2x(): AZP (zenithal/azimuthal perspective)
83 * - szpset(), szpx2s(), szps2x(): SZP (slant zenithal perspective)
84 * - tanset(), tanx2s(), tans2x(): TAN (gnomonic)
85 * - stgset(), stgx2s(), stgs2x(): STG (stereographic)
86 * - sinset(), sinx2s(), sins2x(): SIN (orthographic/synthesis)
87 * - arcset(), arcx2s(), arcs2x(): ARC (zenithal/azimuthal equidistant)
88 * - zpnset(), zpnx2s(), zpns2x(): ZPN (zenithal/azimuthal polynomial)
89 * - zeaset(), zeax2s(), zeas2x(): ZEA (zenithal/azimuthal equal area)
90 * - airset(), airx2s(), airs2x(): AIR (Airy)
91 * - cypset(), cypx2s(), cyps2x(): CYP (cylindrical perspective)
92 * - ceaset(), ceax2s(), ceas2x(): CEA (cylindrical equal area)
93 * - carset(), carx2s(), cars2x(): CAR (Plate carree)
94 * - merset(), merx2s(), mers2x(): MER (Mercator)
95 * - sflset(), sflx2s(), sfls2x(): SFL (Sanson-Flamsteed)
96 * - parset(), parx2s(), pars2x(): PAR (parabolic)
97 * - molset(), molx2s(), mols2x(): MOL (Mollweide)
98 * - aitset(), aitx2s(), aits2x(): AIT (Hammer-Aitoff)
99 * - copset(), copx2s(), cops2x(): COP (conic perspective)
100 * - coeset(), coex2s(), coes2x(): COE (conic equal area)
101 * - codset(), codx2s(), cods2x(): COD (conic equidistant)
102 * - cooset(), coox2s(), coos2x(): COO (conic orthomorphic)
103 * - bonset(), bonx2s(), bons2x(): BON (Bonne)
104 * - pcoset(), pcox2s(), pcos2x(): PCO (polyconic)
105 * - tscset(), tscx2s(), tscs2x(): TSC (tangential spherical cube)
106 * - cscset(), cscx2s(), cscs2x(): CSC (COBE spherical cube)
107 * - qscset(), qscx2s(), qscs2x(): QSC (quadrilateralized spherical cube)
108 * - hpxset(), hpxx2s(), hpxs2x(): HPX (HEALPix)
109 * - xphset(), xphx2s(), xphs2x(): XPH (HEALPix polar, aka "butterfly")
110 *
111 * Argument checking (projection routines):
112 * ----------------------------------------
113 * The values of phi and theta (the native longitude and latitude) normally lie
114 * in the range [-180,180] for phi, and [-90,90] for theta. However, all
115 * projection routines will accept any value of phi and will not normalize it.
116 *
117 * The projection routines do not explicitly check that theta lies within the
118 * range [-90,90]. They do check for any value of theta that produces an
119 * invalid argument to the projection equations (e.g. leading to division by
120 * zero). The projection routines for AZP, SZP, TAN, SIN, ZPN, and COP also
121 * return error 2 if (phi,theta) corresponds to the overlapped (far) side of
122 * the projection but also return the corresponding value of (x,y). This
123 * strict bounds checking may be relaxed at any time by setting
124 * prjprm::bounds%2 to 0 (rather than 1); the projections need not be
125 * reinitialized.
126 *
127 * Argument checking (deprojection routines):
128 * ------------------------------------------
129 * Error checking on the projected coordinates (x,y) is limited to that
130 * required to ascertain whether a solution exists. Where a solution does
131 * exist, an optional check is made that the value of phi and theta obtained
132 * lie within the ranges [-180,180] for phi, and [-90,90] for theta. This
133 * check, performed by prjbchk(), is enabled by default. It may be disabled by
134 * setting prjprm::bounds%4 to 0 (rather than 1); the projections need not be
135 * reinitialized.
136 *
137 * Accuracy:
138 * ---------
139 * No warranty is given for the accuracy of these routines (refer to the
140 * copyright notice); intending users must satisfy for themselves their
141 * adequacy for the intended purpose. However, closure to a precision of at
142 * least 1E-10 degree of longitude and latitude has been verified for typical
143 * projection parameters on the 1 degree graticule of native longitude and
144 * latitude (to within 5 degrees of any latitude where the projection may
145 * diverge). Refer to the tprj1.c and tprj2.c test routines that accompany
146 * this software.
147 *
148 *
149 * prjini() - Default constructor for the prjprm struct
150 * ----------------------------------------------------
151 * prjini() sets all members of a prjprm struct to default values. It should
152 * be used to initialize every prjprm struct.
153 *
154 * Returned:
155 * prj struct prjprm*
156 * Projection parameters.
157 *
158 * Function return value:
159 * int Status return value:
160 * 0: Success.
161 * 1: Null prjprm pointer passed.
162 *
163 *
164 * prjfree() - Destructor for the prjprm struct
165 * --------------------------------------------
166 * prjfree() frees any memory that may have been allocated to store an error
167 * message in the prjprm struct.
168 *
169 * Given:
170 * prj struct prjprm*
171 * Projection parameters.
172 *
173 * Function return value:
174 * int Status return value:
175 * 0: Success.
176 * 1: Null prjprm pointer passed.
177 *
178 *
179 * prjprt() - Print routine for the prjprm struct
180 * ----------------------------------------------
181 * prjprt() prints the contents of a prjprm struct using wcsprintf(). Mainly
182 * intended for diagnostic purposes.
183 *
184 * Given:
185 * prj const struct prjprm*
186 * Projection parameters.
187 *
188 * Function return value:
189 * int Status return value:
190 * 0: Success.
191 * 1: Null prjprm pointer passed.
192 *
193 *
194 * prjbchk() - Bounds checking on native coordinates
195 * -------------------------------------------------
196 * prjbchk() performs bounds checking on native spherical coordinates. As
197 * returned by the deprojection (x2s) routines, native longitude is expected
198 * to lie in the closed interval [-180,180], with latitude in [-90,90].
199 *
200 * A tolerance may be specified to provide a small allowance for numerical
201 * imprecision. Values that lie outside the allowed range by not more than
202 * the specified tolerance will be adjusted back into range.
203 *
204 * If prjprm::bounds&4 is set, as it is by prjini(), then prjbchk() will be
205 * invoked automatically by the Cartesian-to-spherical deprojection (x2s)
206 * routines with an appropriate tolerance set for each projection.
207 *
208 * Given:
209 * tol double Tolerance for the bounds check [deg].
210 *
211 * nphi,
212 * ntheta int Vector lengths.
213 *
214 * spt int Vector stride.
215 *
216 * Given and returned:
217 * phi,theta double[] Native longitude and latitude (phi,theta) [deg].
218 *
219 * Returned:
220 * stat int[] Status value for each vector element:
221 * 0: Valid value of (phi,theta).
222 * 1: Invalid value.
223 *
224 * Function return value:
225 * int Status return value:
226 * 0: Success.
227 * 1: One or more of the (phi,theta) coordinates
228 * were, invalid, as indicated by the stat vector.
229 *
230 *
231 * prjset() - Generic setup routine for the prjprm struct
232 * ------------------------------------------------------
233 * prjset() sets up a prjprm struct according to information supplied within
234 * it.
235 *
236 * Note that this routine need not be called directly; it will be invoked by
237 * prjx2s() and prjs2x() if prj.flag is anything other than a predefined magic
238 * value.
239 *
240 * The one important distinction between prjset() and the setup routines for
241 * the specific projections is that the projection code must be defined in the
242 * prjprm struct in order for prjset() to identify the required projection.
243 * Once prjset() has initialized the prjprm struct, prjx2s() and prjs2x() use
244 * the pointers to the specific projection and deprojection routines contained
245 * therein.
246 *
247 * Given and returned:
248 * prj struct prjprm*
249 * Projection parameters.
250 *
251 * Function return value:
252 * int Status return value:
253 * 0: Success.
254 * 1: Null prjprm pointer passed.
255 * 2: Invalid projection parameters.
256 *
257 * For returns > 1, a detailed error message is set in
258 * prjprm::err if enabled, see wcserr_enable().
259 *
260 *
261 * prjx2s() - Generic Cartesian-to-spherical deprojection
262 * ------------------------------------------------------
263 * Deproject Cartesian (x,y) coordinates in the plane of projection to native
264 * spherical coordinates (phi,theta).
265 *
266 * The projection is that specified by prjprm::code.
267 *
268 * Given and returned:
269 * prj struct prjprm*
270 * Projection parameters.
271 *
272 * Given:
273 * nx,ny int Vector lengths.
274 *
275 * sxy,spt int Vector strides.
276 *
277 * x,y const double[]
278 * Projected coordinates.
279 *
280 * Returned:
281 * phi,theta double[] Longitude and latitude (phi,theta) of the projected
282 * point in native spherical coordinates [deg].
283 *
284 * stat int[] Status value for each vector element:
285 * 0: Success.
286 * 1: Invalid value of (x,y).
287 *
288 * Function return value:
289 * int Status return value:
290 * 0: Success.
291 * 1: Null prjprm pointer passed.
292 * 2: Invalid projection parameters.
293 * 3: One or more of the (x,y) coordinates were
294 * invalid, as indicated by the stat vector.
295 *
296 * For returns > 1, a detailed error message is set in
297 * prjprm::err if enabled, see wcserr_enable().
298 *
299 *
300 * prjs2x() - Generic spherical-to-Cartesian projection
301 * ----------------------------------------------------
302 * Project native spherical coordinates (phi,theta) to Cartesian (x,y)
303 * coordinates in the plane of projection.
304 *
305 * The projection is that specified by prjprm::code.
306 *
307 * Given and returned:
308 * prj struct prjprm*
309 * Projection parameters.
310 *
311 * Given:
312 * nphi,
313 * ntheta int Vector lengths.
314 *
315 * spt,sxy int Vector strides.
316 *
317 * phi,theta const double[]
318 * Longitude and latitude (phi,theta) of the projected
319 * point in native spherical coordinates [deg].
320 *
321 * Returned:
322 * x,y double[] Projected coordinates.
323 *
324 * stat int[] Status value for each vector element:
325 * 0: Success.
326 * 1: Invalid value of (phi,theta).
327 *
328 * Function return value:
329 * int Status return value:
330 * 0: Success.
331 * 1: Null prjprm pointer passed.
332 * 2: Invalid projection parameters.
333 * 4: One or more of the (phi,theta) coordinates
334 * were, invalid, as indicated by the stat vector.
335 *
336 * For returns > 1, a detailed error message is set in
337 * prjprm::err if enabled, see wcserr_enable().
338 *
339 *
340 * ???set() - Specific setup routines for the prjprm struct
341 * --------------------------------------------------------
342 * Set up a prjprm struct for a particular projection according to information
343 * supplied within it.
344 *
345 * Given and returned:
346 * prj struct prjprm*
347 * Projection parameters.
348 *
349 * Function return value:
350 * int Status return value:
351 * 0: Success.
352 * 1: Null prjprm pointer passed.
353 * 2: Invalid projection parameters.
354 *
355 * For returns > 1, a detailed error message is set in
356 * prjprm::err if enabled, see wcserr_enable().
357 *
358 *
359 * ???x2s() - Specific Cartesian-to-spherical deprojection routines
360 * ----------------------------------------------------------------
361 * Transform (x,y) coordinates in the plane of projection to native spherical
362 * coordinates (phi,theta).
363 *
364 * Given and returned:
365 * prj struct prjprm*
366 * Projection parameters.
367 *
368 * Given:
369 * nx,ny int Vector lengths.
370 *
371 * sxy,spt int Vector strides.
372 *
373 * x,y const double[]
374 * Projected coordinates.
375 *
376 * Returned:
377 * phi,theta double[] Longitude and latitude of the projected point in
378 * native spherical coordinates [deg].
379 *
380 * stat int[] Status value for each vector element:
381 * 0: Success.
382 * 1: Invalid value of (x,y).
383 *
384 * Function return value:
385 * int Status return value:
386 * 0: Success.
387 * 1: Null prjprm pointer passed.
388 * 2: Invalid projection parameters.
389 * 3: One or more of the (x,y) coordinates were
390 * invalid, as indicated by the stat vector.
391 *
392 * For returns > 1, a detailed error message is set in
393 * prjprm::err if enabled, see wcserr_enable().
394 *
395 *
396 * ???s2x() - Specific spherical-to-Cartesian projection routines
397 *---------------------------------------------------------------
398 * Transform native spherical coordinates (phi,theta) to (x,y) coordinates in
399 * the plane of projection.
400 *
401 * Given and returned:
402 * prj struct prjprm*
403 * Projection parameters.
404 *
405 * Given:
406 * nphi,
407 * ntheta int Vector lengths.
408 *
409 * spt,sxy int Vector strides.
410 *
411 * phi,theta const double[]
412 * Longitude and latitude of the projected point in
413 * native spherical coordinates [deg].
414 *
415 * Returned:
416 * x,y double[] Projected coordinates.
417 *
418 * stat int[] Status value for each vector element:
419 * 0: Success.
420 * 1: Invalid value of (phi,theta).
421 *
422 * Function return value:
423 * int Status return value:
424 * 0: Success.
425 * 1: Null prjprm pointer passed.
426 * 2: Invalid projection parameters.
427 * 4: One or more of the (phi,theta) coordinates
428 * were, invalid, as indicated by the stat vector.
429 *
430 * For returns > 1, a detailed error message is set in
431 * prjprm::err if enabled, see wcserr_enable().
432 *
433 *
434 * prjprm struct - Projection parameters
435 * -------------------------------------
436 * The prjprm struct contains all information needed to project or deproject
437 * native spherical coordinates. It consists of certain members that must be
438 * set by the user ("given") and others that are set by the WCSLIB routines
439 * ("returned"). Some of the latter are supplied for informational purposes
440 * while others are for internal use only.
441 *
442 * int flag
443 * (Given and returned) This flag must be set to zero whenever any of the
444 * following prjprm struct members are set or changed:
445 *
446 * - prjprm::code,
447 * - prjprm::r0,
448 * - prjprm::pv[],
449 * - prjprm::phi0,
450 * - prjprm::theta0.
451 *
452 * This signals the initialization routine (prjset() or ???set()) to
453 * recompute the returned members of the prjprm struct. flag will then be
454 * reset to indicate that this has been done.
455 *
456 * Note that flag need not be reset when prjprm::bounds is changed.
457 *
458 * char code[4]
459 * (Given) Three-letter projection code defined by the FITS standard.
460 *
461 * double r0
462 * (Given) The radius of the generating sphere for the projection, a linear
463 * scaling parameter. If this is zero, it will be reset to its default
464 * value of 180/pi (the value for FITS WCS).
465 *
466 * double pv[30]
467 * (Given) Projection parameters. These correspond to the PVi_ma keywords
468 * in FITS, so pv[0] is PVi_0a, pv[1] is PVi_1a, etc., where i denotes the
469 * latitude-like axis. Many projections use pv[1] (PVi_1a), some also use
470 * pv[2] (PVi_2a) and SZP uses pv[3] (PVi_3a). ZPN is currently the only
471 * projection that uses any of the others.
472 *
473 * Usage of the pv[] array as it applies to each projection is described in
474 * the prologue to each trio of projection routines in prj.c.
475 *
476 * double phi0
477 * (Given) The native longitude, phi_0 [deg], and ...
478 * double theta0
479 * (Given) ... the native latitude, theta_0 [deg], of the reference point,
480 * i.e. the point (x,y) = (0,0). If undefined (set to a magic value by
481 * prjini()) the initialization routine will set this to a
482 * projection-specific default.
483 *
484 * int bounds
485 * (Given) Controls bounds checking. If bounds&1 then enable strict bounds
486 * checking for the spherical-to-Cartesian (s2x) transformation for the
487 * AZP, SZP, TAN, SIN, ZPN, and COP projections. If bounds&2 then enable
488 * strict bounds checking for the Cartesian-to-spherical transformation
489 * (x2s) for the HPX and XPH projections. If bounds&4 then the Cartesian-
490 * to-spherical transformations (x2s) will invoke prjbchk() to perform
491 * bounds checking on the computed native coordinates, with a tolerance set
492 * to suit each projection. bounds is set to 7 by prjini() by default
493 * which enables all checks. Zero it to disable all checking.
494 *
495 * It is not necessary to reset the prjprm struct (via prjset() or
496 * ???set()) when prjprm::bounds is changed.
497 *
498 * The remaining members of the prjprm struct are maintained by the setup
499 * routines and must not be modified elsewhere:
500 *
501 * char name[40]
502 * (Returned) Long name of the projection.
503 *
504 * Provided for information only, not used by the projection routines.
505 *
506 * int category
507 * (Returned) Projection category matching the value of the relevant global
508 * variable:
509 *
510 * - ZENITHAL,
511 * - CYLINDRICAL,
512 * - PSEUDOCYLINDRICAL,
513 * - CONVENTIONAL,
514 * - CONIC,
515 * - POLYCONIC,
516 * - QUADCUBE, and
517 * - HEALPIX.
518 *
519 * The category name may be identified via the prj_categories character
520 * array, e.g.
521 *
522 = struct prjprm prj;
523 = ...
524 = printf("%s\n", prj_categories[prj.category]);
525 *
526 * Provided for information only, not used by the projection routines.
527 *
528 * int pvrange
529 * (Returned) Range of projection parameter indices: 100 times the first
530 * allowed index plus the number of parameters, e.g. TAN is 0 (no
531 * parameters), SZP is 103 (1 to 3), and ZPN is 30 (0 to 29).
532 *
533 * Provided for information only, not used by the projection routines.
534 *
535 * int simplezen
536 * (Returned) True if the projection is a radially-symmetric zenithal
537 * projection.
538 *
539 * Provided for information only, not used by the projection routines.
540 *
541 * int equiareal
542 * (Returned) True if the projection is equal area.
543 *
544 * Provided for information only, not used by the projection routines.
545 *
546 * int conformal
547 * (Returned) True if the projection is conformal.
548 *
549 * Provided for information only, not used by the projection routines.
550 *
551 * int global
552 * (Returned) True if the projection can represent the whole sphere in a
553 * finite, non-overlapped mapping.
554 *
555 * Provided for information only, not used by the projection routines.
556 *
557 * int divergent
558 * (Returned) True if the projection diverges in latitude.
559 *
560 * Provided for information only, not used by the projection routines.
561 *
562 * double x0
563 * (Returned) The offset in x, and ...
564 * double y0
565 * (Returned) ... the offset in y used to force (x,y) = (0,0) at
566 * (phi_0,theta_0).
567 *
568 * struct wcserr *err
569 * (Returned) If enabled, when an error status is returned, this struct
570 * contains detailed information about the error, see wcserr_enable().
571 *
572 * void *padding
573 * (An unused variable inserted for alignment purposes only.)
574 *
575 * double w[10]
576 * (Returned) Intermediate floating-point values derived from the
577 * projection parameters, cached here to save recomputation.
578 *
579 * Usage of the w[] array as it applies to each projection is described in
580 * the prologue to each trio of projection routines in prj.c.
581 *
582 * int n
583 * (Returned) Intermediate integer value (used only for the ZPN and HPX
584 * projections).
585 *
586 * int (*prjx2s)(PRJX2S_ARGS)
587 * (Returned) Pointer to the spherical projection ...
588 * int (*prjs2x)(PRJ_ARGS)
589 * (Returned) ... and deprojection routines.
590 *
591 *
592 * Global variable: const char *prj_errmsg[] - Status return messages
593 * ------------------------------------------------------------------
594 * Error messages to match the status value returned from each function.
595 *
596 *===========================================================================*/
597 
598 #ifndef WCSLIB_PROJ
599 #define WCSLIB_PROJ
600 
601 #ifdef __cplusplus
602 extern "C" {
603 #endif
604 
605 
606 /* Total number of projection parameters; 0 to PVN-1. */
607 #define PVN 30
608 
609 extern const char *prj_errmsg[];
610 
612  PRJERR_SUCCESS = 0, /* Success. */
613  PRJERR_NULL_POINTER = 1, /* Null prjprm pointer passed. */
614  PRJERR_BAD_PARAM = 2, /* Invalid projection parameters. */
615  PRJERR_BAD_PIX = 3, /* One or more of the (x, y) coordinates were
616  invalid. */
617  PRJERR_BAD_WORLD = 4 /* One or more of the (phi, theta) coordinates
618  were invalid. */
619 };
620 
621 extern const int CONIC, CONVENTIONAL, CYLINDRICAL, POLYCONIC,
623 extern const char prj_categories[9][32];
624 
625 extern const int prj_ncode;
626 extern const char prj_codes[28][4];
627 
628 #ifdef PRJX2S_ARGS
629 #undef PRJX2S_ARGS
630 #endif
631 
632 #ifdef PRJS2X_ARGS
633 #undef PRJS2X_ARGS
634 #endif
635 
636 /* For use in declaring deprojection function prototypes. */
637 #define PRJX2S_ARGS struct prjprm *prj, int nx, int ny, int sxy, int spt, \
638 const double x[], const double y[], double phi[], double theta[], int stat[]
639 
640 /* For use in declaring projection function prototypes. */
641 #define PRJS2X_ARGS struct prjprm *prj, int nx, int ny, int sxy, int spt, \
642 const double phi[], const double theta[], double x[], double y[], int stat[]
643 
644 
645 struct prjprm {
646  /* Initialization flag (see the prologue above). */
647  /*------------------------------------------------------------------------*/
648  int flag; /* Set to zero to force initialization. */
649 
650  /* Parameters to be provided (see the prologue above). */
651  /*------------------------------------------------------------------------*/
652  char code[4]; /* Three-letter projection code. */
653  double r0; /* Radius of the generating sphere. */
654  double pv[PVN]; /* Projection parameters. */
655  double phi0, theta0; /* Fiducial native coordinates. */
656  int bounds; /* Controls bounds checking. */
657 
658  /* Information derived from the parameters supplied. */
659  /*------------------------------------------------------------------------*/
660  char name[40]; /* Projection name. */
661  int category; /* Projection category. */
662  int pvrange; /* Range of projection parameter indices. */
663  int simplezen; /* Is it a simple zenithal projection? */
664  int equiareal; /* Is it an equal area projection? */
665  int conformal; /* Is it a conformal projection? */
666  int global; /* Can it map the whole sphere? */
667  int divergent; /* Does the projection diverge in latitude? */
668  double x0, y0; /* Fiducial offsets. */
669 
670  /* Error handling */
671  /*------------------------------------------------------------------------*/
672  struct wcserr *err;
673 
674  /* Private */
675  /*------------------------------------------------------------------------*/
676  void *padding; /* (Dummy inserted for alignment purposes.) */
677  double w[10]; /* Intermediate values. */
678  int m, n; /* Intermediate values. */
679 
680  int (*prjx2s)(PRJX2S_ARGS); /* Pointers to the spherical projection and */
681  int (*prjs2x)(PRJS2X_ARGS); /* deprojection functions. */
682 };
683 
684 /* Size of the prjprm struct in int units, used by the Fortran wrappers. */
685 #define PRJLEN (sizeof(struct prjprm)/sizeof(int))
686 
687 
688 /* Use the preprocessor to help declare function prototypes (see above). */
689 int prjini(struct prjprm *prj);
690 int prjfree(struct prjprm *prj);
691 int prjprt(const struct prjprm *prj);
692 int prjbchk(double tol, int nx, int ny, int spt, double phi[], double theta[],
693  int stat[]);
694 
695 int prjset(struct prjprm *prj);
696 int prjx2s(PRJX2S_ARGS);
697 int prjs2x(PRJS2X_ARGS);
698 
699 int azpset(struct prjprm *prj);
700 int azpx2s(PRJX2S_ARGS);
701 int azps2x(PRJS2X_ARGS);
702 
703 int szpset(struct prjprm *prj);
704 int szpx2s(PRJX2S_ARGS);
705 int szps2x(PRJS2X_ARGS);
706 
707 int tanset(struct prjprm *prj);
708 int tanx2s(PRJX2S_ARGS);
709 int tans2x(PRJS2X_ARGS);
710 
711 int stgset(struct prjprm *prj);
712 int stgx2s(PRJX2S_ARGS);
713 int stgs2x(PRJS2X_ARGS);
714 
715 int sinset(struct prjprm *prj);
716 int sinx2s(PRJX2S_ARGS);
717 int sins2x(PRJS2X_ARGS);
718 
719 int arcset(struct prjprm *prj);
720 int arcx2s(PRJX2S_ARGS);
721 int arcs2x(PRJS2X_ARGS);
722 
723 int zpnset(struct prjprm *prj);
724 int zpnx2s(PRJX2S_ARGS);
725 int zpns2x(PRJS2X_ARGS);
726 
727 int zeaset(struct prjprm *prj);
728 int zeax2s(PRJX2S_ARGS);
729 int zeas2x(PRJS2X_ARGS);
730 
731 int airset(struct prjprm *prj);
732 int airx2s(PRJX2S_ARGS);
733 int airs2x(PRJS2X_ARGS);
734 
735 int cypset(struct prjprm *prj);
736 int cypx2s(PRJX2S_ARGS);
737 int cyps2x(PRJS2X_ARGS);
738 
739 int ceaset(struct prjprm *prj);
740 int ceax2s(PRJX2S_ARGS);
741 int ceas2x(PRJS2X_ARGS);
742 
743 int carset(struct prjprm *prj);
744 int carx2s(PRJX2S_ARGS);
745 int cars2x(PRJS2X_ARGS);
746 
747 int merset(struct prjprm *prj);
748 int merx2s(PRJX2S_ARGS);
749 int mers2x(PRJS2X_ARGS);
750 
751 int sflset(struct prjprm *prj);
752 int sflx2s(PRJX2S_ARGS);
753 int sfls2x(PRJS2X_ARGS);
754 
755 int parset(struct prjprm *prj);
756 int parx2s(PRJX2S_ARGS);
757 int pars2x(PRJS2X_ARGS);
758 
759 int molset(struct prjprm *prj);
760 int molx2s(PRJX2S_ARGS);
761 int mols2x(PRJS2X_ARGS);
762 
763 int aitset(struct prjprm *prj);
764 int aitx2s(PRJX2S_ARGS);
765 int aits2x(PRJS2X_ARGS);
766 
767 int copset(struct prjprm *prj);
768 int copx2s(PRJX2S_ARGS);
769 int cops2x(PRJS2X_ARGS);
770 
771 int coeset(struct prjprm *prj);
772 int coex2s(PRJX2S_ARGS);
773 int coes2x(PRJS2X_ARGS);
774 
775 int codset(struct prjprm *prj);
776 int codx2s(PRJX2S_ARGS);
777 int cods2x(PRJS2X_ARGS);
778 
779 int cooset(struct prjprm *prj);
780 int coox2s(PRJX2S_ARGS);
781 int coos2x(PRJS2X_ARGS);
782 
783 int bonset(struct prjprm *prj);
784 int bonx2s(PRJX2S_ARGS);
785 int bons2x(PRJS2X_ARGS);
786 
787 int pcoset(struct prjprm *prj);
788 int pcox2s(PRJX2S_ARGS);
789 int pcos2x(PRJS2X_ARGS);
790 
791 int tscset(struct prjprm *prj);
792 int tscx2s(PRJX2S_ARGS);
793 int tscs2x(PRJS2X_ARGS);
794 
795 int cscset(struct prjprm *prj);
796 int cscx2s(PRJX2S_ARGS);
797 int cscs2x(PRJS2X_ARGS);
798 
799 int qscset(struct prjprm *prj);
800 int qscx2s(PRJX2S_ARGS);
801 int qscs2x(PRJS2X_ARGS);
802 
803 int hpxset(struct prjprm *prj);
804 int hpxx2s(PRJX2S_ARGS);
805 int hpxs2x(PRJS2X_ARGS);
806 
807 int xphset(struct prjprm *prj);
808 int xphx2s(PRJX2S_ARGS);
809 int xphs2x(PRJS2X_ARGS);
810 
811 
812 /* Deprecated. */
813 #define prjini_errmsg prj_errmsg
814 #define prjprt_errmsg prj_errmsg
815 #define prjset_errmsg prj_errmsg
816 #define prjx2s_errmsg prj_errmsg
817 #define prjs2x_errmsg prj_errmsg
818 
819 #ifdef __cplusplus
820 }
821 #endif
822 
823 #endif /* WCSLIB_PROJ */
int sinx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the orthographic/synthesis (SIN) projection.
int cars2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the plate carrée (CAR) projection.
int molset(struct prjprm *prj)
Set up a prjprm struct for Mollweide's (MOL) projection.
int stgset(struct prjprm *prj)
Set up a prjprm struct for the stereographic (STG) projection.
int tanset(struct prjprm *prj)
Set up a prjprm struct for the gnomonic (TAN) projection.
int prjprt(const struct prjprm *prj)
Print routine for the prjprm struct.
const int CONVENTIONAL
Identifier for conventional projections.
int arcx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal equidistant (ARC) projection...
int arcset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal equidistant (ARC) projection.
int bonx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Bonne's (BON) projection.
int simplezen
Definition: prj.h:663
int coeset(struct prjprm *prj)
Set up a prjprm struct for the conic equal area (COE) projection.
Error message handling.
Definition: wcserr.h:225
int equiareal
Definition: prj.h:664
int sflset(struct prjprm *prj)
Set up a prjprm struct for the Sanson-Flamsteed (SFL) projection.
int bons2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Bonne's (BON) projection.
int m
Definition: prj.h:678
const char prj_categories[9][32]
Projection categories.
int copset(struct prjprm *prj)
Set up a prjprm struct for the conic perspective (COP) projection.
int tanx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the gnomonic (TAN) projection.
int airx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Airy's (AIR) projection.
int xphs2x(PRJS2X_ARGS)
prj_errmsg_enum
Definition: prj.h:611
int stgx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the stereographic (STG) projection.
const char prj_codes[28][4]
Recognized three-letter projection codes.
int szpset(struct prjprm *prj)
Set up a prjprm struct for the slant zenithal perspective (SZP) projection.
int aits2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the Hammer-Aitoff (AIT) projection.
int cooset(struct prjprm *prj)
Set up a prjprm struct for the conic orthomorphic (COO) projection.
int zpns2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal polynomial (ZPN) projection...
int merx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Mercator's (MER) projection.
int merset(struct prjprm *prj)
Set up a prjprm struct for Mercator's (MER) projection.
int parx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the parabolic (PAR) projection.
int coes2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic equal area (COE) projection.
Definition: prj.h:617
Definition: prj.h:614
int carx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the plate carrée (CAR) projection.
void * padding
Definition: prj.h:676
double pv[PVN]
Definition: prj.h:654
int(* prjs2x)(PRJS2X_ARGS)
Definition: prj.h:681
int cypx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the cylindrical perspective (CYP) projection.
int cscset(struct prjprm *prj)
Set up a prjprm struct for the COBE spherical cube (CSC) projection.
int category
Definition: prj.h:661
int aitset(struct prjprm *prj)
Set up a prjprm struct for the Hammer-Aitoff (AIT) projection.
const int CYLINDRICAL
Identifier for cylindrical projections.
int cops2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic perspective (COP) projection. ...
int pcox2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the polyconic (PCO) projection.
int prjfree(struct prjprm *prj)
Destructor for the prjprm struct.
int carset(struct prjprm *prj)
Set up a prjprm struct for the plate carrée (CAR) projection.
int xphx2s(PRJX2S_ARGS)
int tscset(struct prjprm *prj)
Set up a prjprm struct for the tangential spherical cube (TSC) projection.
int prjs2x(PRJS2X_ARGS)
Generic spherical-to-Cartesian projection.
int cscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the COBE spherical cube (CSC) projection.
int airset(struct prjprm *prj)
Set up a prjprm struct for Airy's (AIR) projection.
int cscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the COBE spherical cube (CSC) projection.
Projection parameters.
Definition: prj.h:645
int pcos2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the polyconic (PCO) projection.
int szps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the slant zenithal perspective (SZP) projection.
int zeax2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal equal area (ZEA) projection...
int qscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the quadrilateralized spherical cube (QSC) projection...
double phi0
Definition: prj.h:655
double r0
Definition: prj.h:653
const int POLYCONIC
Identifier for polyconic projections.
int qscset(struct prjprm *prj)
Set up a prjprm struct for the quadrilateralized spherical cube (QSC) projection. ...
int prjbchk(double tol, int nx, int ny, int spt, double phi[], double theta[], int stat[])
Bounds checking on native coordinates.
int zeaset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal equal area (ZEA) projection.
int sinset(struct prjprm *prj)
Set up a prjprm struct for the orthographic/synthesis (SIN) projection.
char code[4]
Definition: prj.h:652
int(* prjx2s)(PRJX2S_ARGS)
Definition: prj.h:680
#define PRJS2X_ARGS
For use in declaring projection function prototypes.
Definition: prj.h:641
int hpxset(struct prjprm *prj)
Set up a prjprm struct for the HEALPix (HPX) projection.
const int QUADCUBE
Identifier for quadcube projections.
int sflx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the Sanson-Flamsteed (SFL) projection.
const char * prj_errmsg[]
Status return messages.
const int prj_ncode
The number of recognized three-letter projection codes.
int zeas2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal equal area (ZEA) projection...
int airs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Airy's (AIR) projection.
int tscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the tangential spherical cube (TSC) projection.
char name[40]
Definition: prj.h:660
int copx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic perspective (COP) projection. ...
double x0
Definition: prj.h:668
int cods2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic equidistant (COD) projection. ...
int prjset(struct prjprm *prj)
Generic setup routine for the prjprm struct.
int conformal
Definition: prj.h:665
int pvrange
Definition: prj.h:662
int sins2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the orthographic/synthesis (SIN) projection.
const int CONIC
Identifier for conic projections.
int cyps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the cylindrical perspective (CYP) projection.
int arcs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal equidistant (ARC) projection...
double w[10]
Definition: prj.h:677
int n
Definition: prj.h:678
const int HEALPIX
Identifier for the HEALPix projection.
int mers2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Mercator's (MER) projection.
int codset(struct prjprm *prj)
Set up a prjprm struct for the conic equidistant (COD) projection.
int tscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the tangential spherical cube (TSC) projection.
const int ZENITHAL
Identifier for zenithal/azimuthal projections.
int coox2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic orthomorphic (COO) projection.
int qscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the quadrilateralized spherical cube (QSC) projection...
int hpxx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the HEALPix (HPX) projection.
int bonset(struct prjprm *prj)
Set up a prjprm struct for Bonne's (BON) projection.
int coex2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic equal area (COE) projection.
int xphset(struct prjprm *prj)
const int PSEUDOCYLINDRICAL
Identifier for pseudocylindrical projections.
Definition: prj.h:613
int szpx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the slant zenithal perspective (SZP) projection.
#define PVN
Total number of projection parameters.
Definition: prj.h:607
Definition: prj.h:615
int ceas2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the cylindrical equal area (CEA) projection.
double y0
Definition: prj.h:668
int coos2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic orthomorphic (COO) projection.
int aitx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the Hammer-Aitoff (AIT) projection.
int zpnset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal polynomial (ZPN) projection.
int sfls2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the Sanson-Flamsteed (SFL) projection.
int mols2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Mollweide's (MOL) projection.
int global
Definition: prj.h:666
int pcoset(struct prjprm *prj)
Set up a prjprm struct for the polyconic (PCO) projection.
int ceaset(struct prjprm *prj)
Set up a prjprm struct for the cylindrical equal area (CEA) projection.
int prjini(struct prjprm *prj)
Default constructor for the prjprm struct.
int bounds
Definition: prj.h:656
struct wcserr * err
Definition: prj.h:672
int tans2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the gnomonic (TAN) projection.
int azpset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal perspective (AZP) projection.
int flag
Definition: prj.h:648
int parset(struct prjprm *prj)
Set up a prjprm struct for the parabolic (PAR) projection.
int azps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal perspective (AZP) projection...
int stgs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the stereographic (STG) projection.
int ceax2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the cylindrical equal area (CEA) projection.
int hpxs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the HEALPix (HPX) projection.
int zpnx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal polynomial (ZPN) projection...
int azpx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal perspective (AZP) projection...
int prjx2s(PRJX2S_ARGS)
Generic Cartesian-to-spherical deprojection.
int molx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Mollweide's (MOL) projection.
Definition: prj.h:612
#define PRJX2S_ARGS
For use in declaring deprojection function prototypes.
Definition: prj.h:637
double theta0
Definition: prj.h:655
int divergent
Definition: prj.h:667
int pars2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the parabolic (PAR) projection.
int cypset(struct prjprm *prj)
Set up a prjprm struct for the cylindrical perspective (CYP) projection.
int codx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic equidistant (COD) projection. ...