WCSLIB: lin.h Source File

WCSLIB 7.3.1

lin.h
Go to the documentation of this file.
1 /*============================================================================
2 WCSLIB 7.3 - an implementation of the FITS WCS standard.
3 Copyright (C) 1995-2020, Mark Calabretta
4
5 This file is part of WCSLIB.
6
7 WCSLIB is free software: you can redistribute it and/or modify it under the
8 terms of the GNU Lesser General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or (at your option)
10 any later version.
11
12 WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with WCSLIB. If not, see http://www.gnu.org/licenses.
19
20 Direct correspondence concerning WCSLIB to mark@calabretta.id.au
21
22 Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
23 http://www.atnf.csiro.au/people/Mark.Calabretta
24 $Id: lin.h,v 7.3.1.2 2020/08/17 11:19:09 mcalabre Exp mcalabre $
25 *=============================================================================
26 *
27 * WCSLIB 7.3 - C routines that implement the FITS World Coordinate System
28 * (WCS) standard. Refer to the README file provided with WCSLIB for an
29 * overview of the library.
30 *
31 *
32 * Summary of the lin routines
33 * ---------------------------
34 * Routines in this suite apply the linear transformation defined by the FITS
35 * World Coordinate System (WCS) standard, as described in
36 *
37 = "Representations of world coordinates in FITS",
38 = Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (WCS Paper I)
39 *
40 * These routines are based on the linprm struct which contains all information
41 * needed for the computations. The struct contains some members that must be
42 * set by the user, and others that are maintained by these routines, somewhat
43 * like a C++ class but with no encapsulation.
44 *
45 * Six routines, linini(), lininit(), lindis(), lindist() lincpy(), and
46 * linfree() are provided to manage the linprm struct, and another, linprt(),
47 * prints its contents.
48 *
49 * linperr() prints the error message(s) (if any) stored in a linprm struct,
50 * and the disprm structs that it may contain.
51 *
52 * A setup routine, linset(), computes intermediate values in the linprm struct
53 * from parameters in it that were supplied by the user. The struct always
54 * needs to be set up by linset() but need not be called explicitly - refer to
55 * the explanation of linprm::flag.
56 *
57 * linp2x() and linx2p() implement the WCS linear transformations.
58 *
59 * An auxiliary routine, linwarp(), computes various measures of the distortion
60 * over a specified range of pixel coordinates.
61 *
62 * An auxiliary matrix inversion routine, matinv(), is included. It uses
63 * LU-triangular factorization with scaled partial pivoting.
64 *
65 *
66 * linini() - Default constructor for the linprm struct
67 * ----------------------------------------------------
68 * linini() is a thin wrapper on lininit(). It invokes it with ndpmax set
69 * to -1 which causes it to use the value of the global variable NDPMAX. It
70 * is thereby potentially thread-unsafe if NDPMAX is altered dynamically via
71 * disndp(). Use lininit() for a thread-safe alternative in this case.
72 *
73 *
74 * lininit() - Default constructor for the linprm struct
75 * -----------------------------------------------------
76 * lininit() allocates memory for arrays in a linprm struct and sets all
77 * members of the struct to default values.
78 *
79 * PLEASE NOTE: every linprm struct must be initialized by lininit(), possibly
80 * repeatedly. On the first invokation, and only the first invokation,
81 * linprm::flag must be set to -1 to initialize memory management, regardless
82 * of whether lininit() will actually be used to allocate memory.
83 *
84 * Given:
85 * alloc int If true, allocate memory unconditionally for arrays in
86 * the linprm struct.
87 *
88 * If false, it is assumed that pointers to these arrays
89 * have been set by the user except if they are null
90 * pointers in which case memory will be allocated for
91 * them regardless. (In other words, setting alloc true
92 * saves having to initalize these pointers to zero.)
93 *
94 * naxis int The number of world coordinate axes, used to determine
95 * array sizes.
96 *
97 * Given and returned:
98 * lin struct linprm*
99 * Linear transformation parameters. Note that, in order
100 * to initialize memory management linprm::flag should be
101 * set to -1 when lin is initialized for the first time
102 * (memory leaks may result if it had already been
103 * initialized).
104 *
105 * Given:
106 * ndpmax int The number of DPja or DQia keywords to allocate space
107 * for. If set to -1, the value of the global variable
108 * NDPMAX will be used. This is potentially
109 * thread-unsafe if disndp() is being used dynamically to
110 * alter its value.
111 *
112 * Function return value:
113 * int Status return value:
114 * 0: Success.
115 * 1: Null linprm pointer passed.
116 * 2: Memory allocation failed.
117 *
118 * For returns > 1, a detailed error message is set in
119 * linprm::err if enabled, see wcserr_enable().
120 *
121 *
122 * lindis() - Assign a distortion to a linprm struct
123 * -------------------------------------------------
124 * lindis() is a thin wrapper on lindist(). It invokes it with ndpmax set
125 * to -1 which causes the value of the global variable NDPMAX to be used (by
126 * disinit()). It is thereby potentially thread-unsafe if NDPMAX is altered
127 * dynamically via disndp(). Use lindist() for a thread-safe alternative in
128 * this case.
129 *
130 *
131 * lindist() - Assign a distortion to a linprm struct
132 * --------------------------------------------------
133 * lindist() may be used to assign the address of a disprm struct to
134 * linprm::dispre or linprm::disseq. The linprm struct must already have been
135 * initialized by lininit().
136 *
137 * The disprm struct must have been allocated from the heap (e.g. using
138 * malloc(), calloc(), etc.). lindist() will immediately initialize it via a
139 * call to disini() using the value of linprm::naxis. Subsequently, it will be
140 * reinitialized by calls to lininit(), and freed by linfree(), neither of
141 * which would happen if the disprm struct was assigned directly.
142 *
143 * If the disprm struct had previously been assigned via lindist(), it will be
144 * freed before reassignment. It is also permissable for a null disprm pointer
145 * to be assigned to disable the distortion correction.
146 *
147 * Given:
148 * sequence int Is it a prior or sequent distortion?
149 * 1: Prior, the assignment is to linprm::dispre.
150 * 2: Sequent, the assignment is to linprm::disseq.
151 *
152 * Anything else is an error.
153 *
154 * Given and returned:
155 * lin struct linprm*
156 * Linear transformation parameters.
157 *
158 * dis struct disprm*
159 * Distortion function parameters.
160 *
161 * Given:
162 * ndpmax int The number of DPja or DQia keywords to allocate space
163 * for. If set to -1, the value of the global variable
164 * NDPMAX will be used. This is potentially
165 * thread-unsafe if disndp() is being used dynamically to
166 * alter its value.
167 *
168 * Function return value:
169 * int Status return value:
170 * 0: Success.
171 * 1: Null linprm pointer passed.
172 * 4: Invalid sequence.
173 *
174 *
175 * lincpy() - Copy routine for the linprm struct
176 * ---------------------------------------------
177 * lincpy() does a deep copy of one linprm struct to another, using lininit()
178 * to allocate memory for its arrays if required. Only the "information to be
179 * provided" part of the struct is copied; a call to linset() is required to
180 * initialize the remainder.
181 *
182 * Given:
183 * alloc int If true, allocate memory for the crpix, pc, and cdelt
184 * arrays in the destination. Otherwise, it is assumed
185 * that pointers to these arrays have been set by the
186 * user except if they are null pointers in which case
187 * memory will be allocated for them regardless.
188 *
189 * linsrc const struct linprm*
190 * Struct to copy from.
191 *
192 * Given and returned:
193 * lindst struct linprm*
194 * Struct to copy to. linprm::flag should be set to -1
195 * if lindst was not previously initialized (memory leaks
196 * may result if it was previously initialized).
197 *
198 * Function return value:
199 * int Status return value:
200 * 0: Success.
201 * 1: Null linprm pointer passed.
202 * 2: Memory allocation failed.
203 *
204 * For returns > 1, a detailed error message is set in
205 * linprm::err if enabled, see wcserr_enable().
206 *
207 *
208 * linfree() - Destructor for the linprm struct
209 * --------------------------------------------
210 * linfree() frees memory allocated for the linprm arrays by lininit() and/or
211 * linset(). lininit() keeps a record of the memory it allocates and linfree()
212 * will only attempt to free this.
213 *
214 * PLEASE NOTE: linfree() must not be invoked on a linprm struct that was not
215 * initialized by lininit().
216 *
217 * Given:
218 * lin struct linprm*
219 * Linear transformation parameters.
220 *
221 * Function return value:
222 * int Status return value:
223 * 0: Success.
224 * 1: Null linprm pointer passed.
225 *
226 *
227 * linprt() - Print routine for the linprm struct
228 * ----------------------------------------------
229 * linprt() prints the contents of a linprm struct using wcsprintf(). Mainly
230 * intended for diagnostic purposes.
231 *
232 * Given:
233 * lin const struct linprm*
234 * Linear transformation parameters.
235 *
236 * Function return value:
237 * int Status return value:
238 * 0: Success.
239 * 1: Null linprm pointer passed.
240 *
241 *
242 * linperr() - Print error messages from a linprm struct
243 * -----------------------------------------------------
244 * linperr() prints the error message(s) (if any) stored in a linprm struct,
245 * and the disprm structs that it may contain. If there are no errors then
246 * nothing is printed. It uses wcserr_prt(), q.v.
247 *
248 * Given:
249 * lin const struct linprm*
250 * Coordinate transformation parameters.
251 *
252 * prefix const char *
253 * If non-NULL, each output line will be prefixed with
254 * this string.
255 *
256 * Function return value:
257 * int Status return value:
258 * 0: Success.
259 * 1: Null linprm pointer passed.
260 *
261 *
262 * linset() - Setup routine for the linprm struct
263 * ----------------------------------------------
264 * linset(), if necessary, allocates memory for the linprm::piximg and
265 * linprm::imgpix arrays and sets up the linprm struct according to information
266 * supplied within it - refer to the explanation of linprm::flag.
267 *
268 * Note that this routine need not be called directly; it will be invoked by
269 * linp2x() and linx2p() if the linprm::flag is anything other than a
270 * predefined magic value.
271 *
272 * Given and returned:
273 * lin struct linprm*
274 * Linear transformation parameters.
275 *
276 * Function return value:
277 * int Status return value:
278 * 0: Success.
279 * 1: Null linprm pointer passed.
280 * 2: Memory allocation failed.
281 * 3: PCi_ja matrix is singular.
282 *
283 * For returns > 1, a detailed error message is set in
284 * linprm::err if enabled, see wcserr_enable().
285 *
286 *
287 * linp2x() - Pixel-to-world linear transformation
288 * -----------------------------------------------
289 * linp2x() transforms pixel coordinates to intermediate world coordinates.
290 *
291 * Given and returned:
292 * lin struct linprm*
293 * Linear transformation parameters.
294 *
295 * Given:
296 * ncoord,
297 * nelem int The number of coordinates, each of vector length nelem
298 * but containing lin.naxis coordinate elements.
299 *
300 * pixcrd const double[ncoord][nelem]
301 * Array of pixel coordinates.
302 *
303 * Returned:
304 * imgcrd double[ncoord][nelem]
305 * Array of intermediate world coordinates.
306 *
307 * Function return value:
308 * int Status return value:
309 * 0: Success.
310 * 1: Null linprm pointer passed.
311 * 2: Memory allocation failed.
312 * 3: PCi_ja matrix is singular.
313 *
314 * For returns > 1, a detailed error message is set in
315 * linprm::err if enabled, see wcserr_enable().
316 *
317 *
318 * linx2p() - World-to-pixel linear transformation
319 * -----------------------------------------------
320 * linx2p() transforms intermediate world coordinates to pixel coordinates.
321 *
322 * Given and returned:
323 * lin struct linprm*
324 * Linear transformation parameters.
325 *
326 * Given:
327 * ncoord,
328 * nelem int The number of coordinates, each of vector length nelem
329 * but containing lin.naxis coordinate elements.
330 *
331 * imgcrd const double[ncoord][nelem]
332 * Array of intermediate world coordinates.
333 *
334 * Returned:
335 * pixcrd double[ncoord][nelem]
336 * Array of pixel coordinates.
337 *
338 * int Status return value:
339 * 0: Success.
340 * 1: Null linprm pointer passed.
341 * 2: Memory allocation failed.
342 * 3: PCi_ja matrix is singular.
343 *
344 * For returns > 1, a detailed error message is set in
345 * linprm::err if enabled, see wcserr_enable().
346 *
347 *
348 * linwarp() - Compute measures of distortion
349 * ------------------------------------------
350 * linwarp() computes various measures of the distortion over a specified range
351 * of pixel coordinates.
352 *
353 * All distortion measures are specified as an offset in pixel coordinates,
354 * as given directly by prior distortions. The offset in intermediate pixel
355 * coordinates given by sequent distortions is translated back to pixel
356 * coordinates by applying the inverse of the linear transformation matrix
357 * (PCi_ja or CDi_ja). The difference may be significant if the matrix
358 * introduced a scaling.
359 *
360 * If all distortions are prior, then linwarp() uses diswarp(), q.v.
361 *
362 * Given and returned:
363 * lin struct linprm*
364 * Linear transformation parameters plus distortions.
365 *
366 * Given:
367 * pixblc const double[naxis]
368 * Start of the range of pixel coordinates (i.e. "bottom
369 * left-hand corner" in the conventional FITS image
370 * display orientation). May be specified as a NULL
371 * pointer which is interpreted as (1,1,...).
372 *
373 * pixtrc const double[naxis]
374 * End of the range of pixel coordinates (i.e. "top
375 * right-hand corner" in the conventional FITS image
376 * display orientation).
377 *
378 * pixsamp const double[naxis]
379 * If positive or zero, the increment on the particular
380 * axis, starting at pixblc[]. Zero is interpreted as a
381 * unit increment. pixsamp may also be specified as a
382 * NULL pointer which is interpreted as all zeroes, i.e.
383 * unit increments on all axes.
384 *
385 * If negative, the grid size on the particular axis (the
386 * absolute value being rounded to the nearest integer).
387 * For example, if pixsamp is (-128.0,-128.0,...) then
388 * each axis will be sampled at 128 points between
389 * pixblc[] and pixtrc[] inclusive. Use caution when
390 * using this option on non-square images.
391 *
392 * Returned:
393 * nsamp int* The number of pixel coordinates sampled.
394 *
395 * Can be specified as a NULL pointer if not required.
396 *
397 * maxdis double[naxis]
398 * For each individual distortion function, the
399 * maximum absolute value of the distortion.
400 *
401 * Can be specified as a NULL pointer if not required.
402 *
403 * maxtot double* For the combination of all distortion functions, the
404 * maximum absolute value of the distortion.
405 *
406 * Can be specified as a NULL pointer if not required.
407 *
408 * avgdis double[naxis]
409 * For each individual distortion function, the
410 * mean value of the distortion.
411 *
412 * Can be specified as a NULL pointer if not required.
413 *
414 * avgtot double* For the combination of all distortion functions, the
415 * mean value of the distortion.
416 *
417 * Can be specified as a NULL pointer if not required.
418 *
419 * rmsdis double[naxis]
420 * For each individual distortion function, the
421 * root mean square deviation of the distortion.
422 *
423 * Can be specified as a NULL pointer if not required.
424 *
425 * rmstot double* For the combination of all distortion functions, the
426 * root mean square deviation of the distortion.
427 *
428 * Can be specified as a NULL pointer if not required.
429 *
430 * Function return value:
431 * int Status return value:
432 * 0: Success.
433 * 1: Null linprm pointer passed.
434 * 2: Memory allocation failed.
435 * 3: Invalid parameter.
436 * 4: Distort error.
437 *
438 *
439 * linprm struct - Linear transformation parameters
440 * ------------------------------------------------
441 * The linprm struct contains all of the information required to perform a
442 * linear transformation. It consists of certain members that must be set by
443 * the user ("given") and others that are set by the WCSLIB routines
444 * ("returned").
445 *
446 * int flag
447 * (Given and returned) This flag must be set to zero whenever any of the
448 * following members of the linprm struct are set or modified:
449 *
450 * - linprm::naxis (q.v., not normally set by the user),
451 * - linprm::pc,
452 * - linprm::cdelt,
453 * - linprm::dispre.
454 * - linprm::disseq.
455 *
456 * This signals the initialization routine, linset(), to recompute the
457 * returned members of the linprm struct. linset() will reset flag to
458 * indicate that this has been done.
459 *
460 * PLEASE NOTE: flag should be set to -1 when lininit() is called for the
461 * first time for a particular linprm struct in order to initialize memory
462 * management. It must ONLY be used on the first initialization otherwise
463 * memory leaks may result.
464 *
465 * int naxis
466 * (Given or returned) Number of pixel and world coordinate elements.
467 *
468 * If lininit() is used to initialize the linprm struct (as would normally
469 * be the case) then it will set naxis from the value passed to it as a
470 * function argument. The user should not subsequently modify it.
471 *
472 * double *crpix
473 * (Given) Pointer to the first element of an array of double containing
474 * the coordinate reference pixel, CRPIXja.
475 *
476 * It is not necessary to reset the linprm struct (via linset()) when
477 * linprm::crpix is changed.
478 *
479 * double *pc
480 * (Given) Pointer to the first element of the PCi_ja (pixel coordinate)
481 * transformation matrix. The expected order is
482 *
483 = struct linprm lin;
484 = lin.pc = {PC1_1, PC1_2, PC2_1, PC2_2};
485 *
486 * This may be constructed conveniently from a 2-D array via
487 *
488 = double m[2][2] = {{PC1_1, PC1_2},
489 = {PC2_1, PC2_2}};
490 *
491 * which is equivalent to
492 *
493 = double m[2][2];
494 = m[0][0] = PC1_1;
495 = m[0][1] = PC1_2;
496 = m[1][0] = PC2_1;
497 = m[1][1] = PC2_2;
498 *
499 * The storage order for this 2-D array is the same as for the 1-D array,
500 * whence
501 *
502 = lin.pc = *m;
503 *
504 * would be legitimate.
505 *
506 * double *cdelt
507 * (Given) Pointer to the first element of an array of double containing
508 * the coordinate increments, CDELTia.
509 *
510 * struct disprm *dispre
511 * (Given) Pointer to a disprm struct holding parameters for prior
512 * distortion functions, or a null (0x0) pointer if there are none.
513 *
514 * Function lindist() may be used to assign a disprm pointer to a linprm
515 * struct, allowing it to take control of any memory allocated for it, as
516 * in the following example:
517 *
518 = void add_distortion(struct linprm *lin)
519 = {
520 = struct disprm *dispre;
521 =
522 = dispre = malloc(sizeof(struct disprm));
523 = dispre->flag = -1;
524 = lindist(1, lin, dispre, ndpmax);
525 = :
526 = (Set up dispre.)
527 = :
528 =
529 = return;
530 = }
531 *
532 * Here, after the distortion function parameters etc. are copied into
533 * dispre, dispre is assigned using lindist() which takes control of the
534 * allocated memory. It will be freed later when linfree() is invoked on
535 * the linprm struct.
536 *
537 * Consider also the following erroneous code:
538 *
539 = void bad_code(struct linprm *lin)
540 = {
541 = struct disprm dispre;
542 =
543 = dispre.flag = -1;
544 = lindist(1, lin, &dispre, ndpmax); // WRONG.
545 = :
546 =
547 = return;
548 = }
549 *
550 * Here, dispre is declared as a struct, rather than a pointer. When the
551 * function returns, dispre will go out of scope and its memory will most
552 * likely be reused, thereby trashing its contents. Later, a segfault will
553 * occur when linfree() tries to free dispre's stale address.
554 *
555 * struct disprm *disseq
556 * (Given) Pointer to a disprm struct holding parameters for sequent
557 * distortion functions, or a null (0x0) pointer if there are none.
558 *
559 * Refer to the comments and examples given for disprm::dispre.
560 *
561 * double *piximg
562 * (Returned) Pointer to the first element of the matrix containing the
563 * product of the CDELTia diagonal matrix and the PCi_ja matrix.
564 *
565 * double *imgpix
566 * (Returned) Pointer to the first element of the inverse of the
567 * linprm::piximg matrix.
568 *
569 * int i_naxis
570 * (Returned) The dimension of linprm::piximg and linprm::imgpix (normally
571 * equal to naxis).
572 *
573 * int unity
574 * (Returned) True if the linear transformation matrix is unity.
575 *
576 * int affine
577 * (Returned) True if there are no distortions.
578 *
579 * int simple
580 * (Returned) True if unity and no distortions.
581 *
582 * struct wcserr *err
583 * (Returned) If enabled, when an error status is returned, this struct
584 * contains detailed information about the error, see wcserr_enable().
585 *
586 * double *tmpcrd
587 * (For internal use only.)
588 * int m_flag
589 * (For internal use only.)
590 * int m_naxis
591 * (For internal use only.)
592 * double *m_crpix
593 * (For internal use only.)
594 * double *m_pc
595 * (For internal use only.)
596 * double *m_cdelt
597 * (For internal use only.)
598 * struct disprm *m_dispre
599 * (For internal use only.)
600 * struct disprm *m_disseq
601 * (For internal use only.)
602 *
603 *
604 * Global variable: const char *lin_errmsg[] - Status return messages
605 * ------------------------------------------------------------------
606 * Error messages to match the status value returned from each function.
607 *
608 *===========================================================================*/
609
610 #ifndef WCSLIB_LIN
611 #define WCSLIB_LIN
612
613 #ifdef __cplusplus
614 extern "C" {
615 #endif
616
617
618 extern const char *lin_errmsg[];
619
620 enum lin_errmsg_enum {
621 LINERR_SUCCESS = 0, // Success.
622 LINERR_NULL_POINTER = 1, // Null linprm pointer passed.
623 LINERR_MEMORY = 2, // Memory allocation failed.
624 LINERR_SINGULAR_MTX = 3, // PCi_ja matrix is singular.
625 LINERR_DISTORT_INIT = 4, // Failed to initialise distortions.
626 LINERR_DISTORT = 5, // Distort error.
627 LINERR_DEDISTORT = 6 // De-distort error.
628 };
629
630 struct linprm {
631 // Initialization flag (see the prologue above).
632 //--------------------------------------------------------------------------
633 int flag; // Set to zero to force initialization.
634
635 // Parameters to be provided (see the prologue above).
636 //--------------------------------------------------------------------------
637 int naxis; // The number of axes, given by NAXIS.
638 double *crpix; // CRPIXja keywords for each pixel axis.
639 double *pc; // PCi_ja linear transformation matrix.
640 double *cdelt; // CDELTia keywords for each coord axis.
641 struct disprm *dispre; // Prior distortion parameters, if any.
642 struct disprm *disseq; // Sequent distortion parameters, if any.
643
644 // Information derived from the parameters supplied.
645 //--------------------------------------------------------------------------
646 double *piximg; // Product of CDELTia and PCi_ja matrices.
647 double *imgpix; // Inverse of the piximg matrix.
648 int i_naxis; // Dimension of piximg and imgpix.
649 int unity; // True if the PCi_ja matrix is unity.
650 int affine; // True if there are no distortions.
651 int simple; // True if unity and no distortions.
652
653 // Error handling, if enabled.
654 //--------------------------------------------------------------------------
655 struct wcserr *err;
656
657 // Private - the remainder are for internal use.
658 //--------------------------------------------------------------------------
659 double *tmpcrd;
660
661 int m_flag, m_naxis;
662 double *m_crpix, *m_pc, *m_cdelt;
663 struct disprm *m_dispre, *m_disseq;
664 };
665
666 // Size of the linprm struct in int units, used by the Fortran wrappers.
667 #define LINLEN (sizeof(struct linprm)/sizeof(int))
668
669
670 int linini(int alloc, int naxis, struct linprm *lin);
671
672 int lininit(int alloc, int naxis, struct linprm *lin, int ndpmax);
673
674 int lindis(int sequence, struct linprm *lin, struct disprm *dis);
675
676 int lindist(int sequence, struct linprm *lin, struct disprm *dis, int ndpmax);
677
678 int lincpy(int alloc, const struct linprm *linsrc, struct linprm *lindst);
679
680 int linfree(struct linprm *lin);
681
682 int linprt(const struct linprm *lin);
683
684 int linperr(const struct linprm *lin, const char *prefix);
685
686 int linset(struct linprm *lin);
687
688 int linp2x(struct linprm *lin, int ncoord, int nelem, const double pixcrd[],
689 double imgcrd[]);
690
691 int linx2p(struct linprm *lin, int ncoord, int nelem, const double imgcrd[],
692 double pixcrd[]);
693
694 int linwarp(struct linprm *lin, const double pixblc[], const double pixtrc[],
695 const double pixsamp[], int *nsamp,
696 double maxdis[], double *maxtot,
697 double avgdis[], double *avgtot,
698 double rmsdis[], double *rmstot);
699
700 int matinv(int n, const double mat[], double inv[]);
701
702
703 // Deprecated.
704 #define linini_errmsg lin_errmsg
705 #define lincpy_errmsg lin_errmsg
706 #define linfree_errmsg lin_errmsg
707 #define linprt_errmsg lin_errmsg
708 #define linset_errmsg lin_errmsg
709 #define linp2x_errmsg lin_errmsg
710 #define linx2p_errmsg lin_errmsg
711
712 #ifdef __cplusplus
713 }
714 #endif
715
716 #endif // WCSLIB_LIN
linprm::err
struct wcserr * err
Definition: lin.h:655
linset
int linset(struct linprm *lin)
Setup routine for the linprm struct.
lindist
int lindist(int sequence, struct linprm *lin, struct disprm *dis, int ndpmax)
Assign a distortion to a linprm struct.
linprm::crpix
double * crpix
Definition: lin.h:638
linprm::m_crpix
double * m_crpix
Definition: lin.h:662
linprm::pc
double * pc
Definition: lin.h:639
linprt
int linprt(const struct linprm *lin)
Print routine for the linprm struct.
linprm::m_pc
double * m_pc
Definition: lin.h:662
linprm::imgpix
double * imgpix
Definition: lin.h:647
LINERR_SINGULAR_MTX
@ LINERR_SINGULAR_MTX
Definition: lin.h:624
lin_errmsg
const char * lin_errmsg[]
Status return messages.
LINERR_DISTORT
@ LINERR_DISTORT
Definition: lin.h:626
disprm::naxis
int naxis
Definition: dis.h:1051
linprm::cdelt
double * cdelt
Definition: lin.h:640
lindis
int lindis(int sequence, struct linprm *lin, struct disprm *dis)
Assign a distortion to a linprm struct.
linfree
int linfree(struct linprm *lin)
Destructor for the linprm struct.
linprm::dispre
struct disprm * dispre
Definition: lin.h:641
linprm::m_disseq
struct disprm * m_disseq
Definition: lin.h:663
disprm::maxdis
double * maxdis
Definition: dis.h:1057
linprm::simple
int simple
Definition: lin.h:651
linprm::naxis
int naxis
Definition: lin.h:637
lin_errmsg_enum
lin_errmsg_enum
Definition: lin.h:620
linprm::m_naxis
int m_naxis
Definition: lin.h:661
linprm::flag
int flag
Definition: lin.h:633
linx2p
int linx2p(struct linprm *lin, int ncoord, int nelem, const double imgcrd[], double pixcrd[])
World-to-pixel linear transformation.
LINERR_SUCCESS
@ LINERR_SUCCESS
Definition: lin.h:621
linprm::piximg
double * piximg
Definition: lin.h:646
linprm::i_naxis
int i_naxis
Definition: lin.h:648
linperr
int linperr(const struct linprm *lin, const char *prefix)
Print error messages from a linprm struct.
linp2x
int linp2x(struct linprm *lin, int ncoord, int nelem, const double pixcrd[], double imgcrd[])
Pixel-to-world linear transformation.
disprm
Distortion parameters.
Definition: dis.h:1044
lininit
int lininit(int alloc, int naxis, struct linprm *lin, int ndpmax)
Default constructor for the linprm struct.
linprm::disseq
struct disprm * disseq
Definition: lin.h:642
LINERR_NULL_POINTER
@ LINERR_NULL_POINTER
Definition: lin.h:622
linprm::unity
int unity
Definition: lin.h:649
LINERR_DISTORT_INIT
@ LINERR_DISTORT_INIT
Definition: lin.h:625
linprm::m_flag
int m_flag
Definition: lin.h:661
linprm::affine
int affine
Definition: lin.h:650
linprm::m_cdelt
double * m_cdelt
Definition: lin.h:662
LINERR_DEDISTORT
@ LINERR_DEDISTORT
Definition: lin.h:627
linprm
Linear transformation parameters.
Definition: lin.h:630
matinv
int matinv(int n, const double mat[], double inv[])
Matrix inversion.
linprm::tmpcrd
double * tmpcrd
Definition: lin.h:659
wcserr
Error message handling.
Definition: wcserr.h:222
LINERR_MEMORY
@ LINERR_MEMORY
Definition: lin.h:623
lincpy
int lincpy(int alloc, const struct linprm *linsrc, struct linprm *lindst)
Copy routine for the linprm struct.
linprm::m_dispre
struct disprm * m_dispre
Definition: lin.h:663
disprm::ndpmax
int ndpmax
Definition: dis.h:1055
linini
int linini(int alloc, int naxis, struct linprm *lin)
Default constructor for the linprm struct.
linwarp
int linwarp(struct linprm *lin, const double pixblc[], const double pixtrc[], const double pixsamp[], int *nsamp, double maxdis[], double *maxtot, double avgdis[], double *avgtot, double rmsdis[], double *rmstot)
Compute measures of distortion.