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