WCSLIB: lin.h Source File

WCSLIB 7.6

lin.h
Go to the documentation of this file.
1 /*============================================================================
2 WCSLIB 7.6 - 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.6 2021/04/13 12:57:01 mcalabre Exp $
23 *=============================================================================
24 *
25 * WCSLIB 7.6 - 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). The second element
240 * is the total allocated size, in bytes, assuming that
241 * the allocation was done by linini(). This figure
242 * includes memory allocated for members of constituent
243 * structs, such as linprm::dispre.
244 *
245 * It is not an error for the struct not to have been set
246 * up via linset(), which normally results in additional
247 * memory allocation.
248 *
249 * Function return value:
250 * int Status return value:
251 * 0: Success.
252 *
253 *
254 * linprt() - Print routine for the linprm struct
255 * ----------------------------------------------
256 * linprt() prints the contents of a linprm struct using wcsprintf(). Mainly
257 * intended for diagnostic purposes.
258 *
259 * Given:
260 * lin const struct linprm*
261 * Linear transformation parameters.
262 *
263 * Function return value:
264 * int Status return value:
265 * 0: Success.
266 * 1: Null linprm pointer passed.
267 *
268 *
269 * linperr() - Print error messages from a linprm struct
270 * -----------------------------------------------------
271 * linperr() prints the error message(s) (if any) stored in a linprm struct,
272 * and the disprm structs that it may contain. If there are no errors then
273 * nothing is printed. It uses wcserr_prt(), q.v.
274 *
275 * Given:
276 * lin const struct linprm*
277 * Coordinate transformation parameters.
278 *
279 * prefix const char *
280 * If non-NULL, each output line will be prefixed with
281 * this string.
282 *
283 * Function return value:
284 * int Status return value:
285 * 0: Success.
286 * 1: Null linprm pointer passed.
287 *
288 *
289 * linset() - Setup routine for the linprm struct
290 * ----------------------------------------------
291 * linset(), if necessary, allocates memory for the linprm::piximg and
292 * linprm::imgpix arrays and sets up the linprm struct according to information
293 * supplied within it - refer to the explanation of linprm::flag.
294 *
295 * Note that this routine need not be called directly; it will be invoked by
296 * linp2x() and linx2p() if the linprm::flag is anything other than a
297 * predefined magic value.
298 *
299 * Given and returned:
300 * lin struct linprm*
301 * Linear transformation parameters.
302 *
303 * Function return value:
304 * int Status return value:
305 * 0: Success.
306 * 1: Null linprm pointer passed.
307 * 2: Memory allocation failed.
308 * 3: PCi_ja matrix is singular.
309 *
310 * For returns > 1, a detailed error message is set in
311 * linprm::err if enabled, see wcserr_enable().
312 *
313 *
314 * linp2x() - Pixel-to-world linear transformation
315 * -----------------------------------------------
316 * linp2x() transforms pixel coordinates to intermediate world coordinates.
317 *
318 * Given and returned:
319 * lin struct linprm*
320 * Linear transformation parameters.
321 *
322 * Given:
323 * ncoord,
324 * nelem int The number of coordinates, each of vector length nelem
325 * but containing lin.naxis coordinate elements.
326 *
327 * pixcrd const double[ncoord][nelem]
328 * Array of pixel coordinates.
329 *
330 * Returned:
331 * imgcrd double[ncoord][nelem]
332 * Array of intermediate world coordinates.
333 *
334 * Function return value:
335 * int Status return value:
336 * 0: Success.
337 * 1: Null linprm pointer passed.
338 * 2: Memory allocation failed.
339 * 3: PCi_ja matrix is singular.
340 *
341 * For returns > 1, a detailed error message is set in
342 * linprm::err if enabled, see wcserr_enable().
343 *
344 *
345 * linx2p() - World-to-pixel linear transformation
346 * -----------------------------------------------
347 * linx2p() transforms intermediate world coordinates to pixel coordinates.
348 *
349 * Given and returned:
350 * lin struct linprm*
351 * Linear transformation parameters.
352 *
353 * Given:
354 * ncoord,
355 * nelem int The number of coordinates, each of vector length nelem
356 * but containing lin.naxis coordinate elements.
357 *
358 * imgcrd const double[ncoord][nelem]
359 * Array of intermediate world coordinates.
360 *
361 * Returned:
362 * pixcrd double[ncoord][nelem]
363 * Array of pixel coordinates.
364 *
365 * int Status return value:
366 * 0: Success.
367 * 1: Null linprm pointer passed.
368 * 2: Memory allocation failed.
369 * 3: PCi_ja matrix is singular.
370 *
371 * For returns > 1, a detailed error message is set in
372 * linprm::err if enabled, see wcserr_enable().
373 *
374 *
375 * linwarp() - Compute measures of distortion
376 * ------------------------------------------
377 * linwarp() computes various measures of the distortion over a specified range
378 * of pixel coordinates.
379 *
380 * All distortion measures are specified as an offset in pixel coordinates,
381 * as given directly by prior distortions. The offset in intermediate pixel
382 * coordinates given by sequent distortions is translated back to pixel
383 * coordinates by applying the inverse of the linear transformation matrix
384 * (PCi_ja or CDi_ja). The difference may be significant if the matrix
385 * introduced a scaling.
386 *
387 * If all distortions are prior, then linwarp() uses diswarp(), q.v.
388 *
389 * Given and returned:
390 * lin struct linprm*
391 * Linear transformation parameters plus distortions.
392 *
393 * Given:
394 * pixblc const double[naxis]
395 * Start of the range of pixel coordinates (i.e. "bottom
396 * left-hand corner" in the conventional FITS image
397 * display orientation). May be specified as a NULL
398 * pointer which is interpreted as (1,1,...).
399 *
400 * pixtrc const double[naxis]
401 * End of the range of pixel coordinates (i.e. "top
402 * right-hand corner" in the conventional FITS image
403 * display orientation).
404 *
405 * pixsamp const double[naxis]
406 * If positive or zero, the increment on the particular
407 * axis, starting at pixblc[]. Zero is interpreted as a
408 * unit increment. pixsamp may also be specified as a
409 * NULL pointer which is interpreted as all zeroes, i.e.
410 * unit increments on all axes.
411 *
412 * If negative, the grid size on the particular axis (the
413 * absolute value being rounded to the nearest integer).
414 * For example, if pixsamp is (-128.0,-128.0,...) then
415 * each axis will be sampled at 128 points between
416 * pixblc[] and pixtrc[] inclusive. Use caution when
417 * using this option on non-square images.
418 *
419 * Returned:
420 * nsamp int* The number of pixel coordinates sampled.
421 *
422 * Can be specified as a NULL pointer if not required.
423 *
424 * maxdis double[naxis]
425 * For each individual distortion function, the
426 * maximum absolute value of the distortion.
427 *
428 * Can be specified as a NULL pointer if not required.
429 *
430 * maxtot double* For the combination of all distortion functions, the
431 * maximum absolute value of the distortion.
432 *
433 * Can be specified as a NULL pointer if not required.
434 *
435 * avgdis double[naxis]
436 * For each individual distortion function, the
437 * mean value of the distortion.
438 *
439 * Can be specified as a NULL pointer if not required.
440 *
441 * avgtot double* For the combination of all distortion functions, the
442 * mean value of the distortion.
443 *
444 * Can be specified as a NULL pointer if not required.
445 *
446 * rmsdis double[naxis]
447 * For each individual distortion function, the
448 * root mean square deviation of the distortion.
449 *
450 * Can be specified as a NULL pointer if not required.
451 *
452 * rmstot double* For the combination of all distortion functions, the
453 * root mean square deviation of the distortion.
454 *
455 * Can be specified as a NULL pointer if not required.
456 *
457 * Function return value:
458 * int Status return value:
459 * 0: Success.
460 * 1: Null linprm pointer passed.
461 * 2: Memory allocation failed.
462 * 3: Invalid parameter.
463 * 4: Distort error.
464 *
465 *
466 * linprm struct - Linear transformation parameters
467 * ------------------------------------------------
468 * The linprm struct contains all of the information required to perform a
469 * linear transformation. It consists of certain members that must be set by
470 * the user ("given") and others that are set by the WCSLIB routines
471 * ("returned").
472 *
473 * int flag
474 * (Given and returned) This flag must be set to zero whenever any of the
475 * following members of the linprm struct are set or modified:
476 *
477 * - linprm::naxis (q.v., not normally set by the user),
478 * - linprm::pc,
479 * - linprm::cdelt,
480 * - linprm::dispre.
481 * - linprm::disseq.
482 *
483 * This signals the initialization routine, linset(), to recompute the
484 * returned members of the linprm struct. linset() will reset flag to
485 * indicate that this has been done.
486 *
487 * PLEASE NOTE: flag should be set to -1 when lininit() is called for the
488 * first time for a particular linprm struct in order to initialize memory
489 * management. It must ONLY be used on the first initialization otherwise
490 * memory leaks may result.
491 *
492 * int naxis
493 * (Given or returned) Number of pixel and world coordinate elements.
494 *
495 * If lininit() is used to initialize the linprm struct (as would normally
496 * be the case) then it will set naxis from the value passed to it as a
497 * function argument. The user should not subsequently modify it.
498 *
499 * double *crpix
500 * (Given) Pointer to the first element of an array of double containing
501 * the coordinate reference pixel, CRPIXja.
502 *
503 * It is not necessary to reset the linprm struct (via linset()) when
504 * linprm::crpix is changed.
505 *
506 * double *pc
507 * (Given) Pointer to the first element of the PCi_ja (pixel coordinate)
508 * transformation matrix. The expected order is
509 *
510 = struct linprm lin;
511 = lin.pc = {PC1_1, PC1_2, PC2_1, PC2_2};
512 *
513 * This may be constructed conveniently from a 2-D array via
514 *
515 = double m[2][2] = {{PC1_1, PC1_2},
516 = {PC2_1, PC2_2}};
517 *
518 * which is equivalent to
519 *
520 = double m[2][2];
521 = m[0][0] = PC1_1;
522 = m[0][1] = PC1_2;
523 = m[1][0] = PC2_1;
524 = m[1][1] = PC2_2;
525 *
526 * The storage order for this 2-D array is the same as for the 1-D array,
527 * whence
528 *
529 = lin.pc = *m;
530 *
531 * would be legitimate.
532 *
533 * double *cdelt
534 * (Given) Pointer to the first element of an array of double containing
535 * the coordinate increments, CDELTia.
536 *
537 * struct disprm *dispre
538 * (Given) Pointer to a disprm struct holding parameters for prior
539 * distortion functions, or a null (0x0) pointer if there are none.
540 *
541 * Function lindist() may be used to assign a disprm pointer to a linprm
542 * struct, allowing it to take control of any memory allocated for it, as
543 * in the following example:
544 *
545 = void add_distortion(struct linprm *lin)
546 = {
547 = struct disprm *dispre;
548 =
549 = dispre = malloc(sizeof(struct disprm));
550 = dispre->flag = -1;
551 = lindist(1, lin, dispre, ndpmax);
552 = :
553 = (Set up dispre.)
554 = :
555 =
556 = return;
557 = }
558 *
559 * Here, after the distortion function parameters etc. are copied into
560 * dispre, dispre is assigned using lindist() which takes control of the
561 * allocated memory. It will be freed later when linfree() is invoked on
562 * the linprm struct.
563 *
564 * Consider also the following erroneous code:
565 *
566 = void bad_code(struct linprm *lin)
567 = {
568 = struct disprm dispre;
569 =
570 = dispre.flag = -1;
571 = lindist(1, lin, &dispre, ndpmax); // WRONG.
572 = :
573 =
574 = return;
575 = }
576 *
577 * Here, dispre is declared as a struct, rather than a pointer. When the
578 * function returns, dispre will go out of scope and its memory will most
579 * likely be reused, thereby trashing its contents. Later, a segfault will
580 * occur when linfree() tries to free dispre's stale address.
581 *
582 * struct disprm *disseq
583 * (Given) Pointer to a disprm struct holding parameters for sequent
584 * distortion functions, or a null (0x0) pointer if there are none.
585 *
586 * Refer to the comments and examples given for disprm::dispre.
587 *
588 * double *piximg
589 * (Returned) Pointer to the first element of the matrix containing the
590 * product of the CDELTia diagonal matrix and the PCi_ja matrix.
591 *
592 * double *imgpix
593 * (Returned) Pointer to the first element of the inverse of the
594 * linprm::piximg matrix.
595 *
596 * int i_naxis
597 * (Returned) The dimension of linprm::piximg and linprm::imgpix (normally
598 * equal to naxis).
599 *
600 * int unity
601 * (Returned) True if the linear transformation matrix is unity.
602 *
603 * int affine
604 * (Returned) True if there are no distortions.
605 *
606 * int simple
607 * (Returned) True if unity and no distortions.
608 *
609 * struct wcserr *err
610 * (Returned) If enabled, when an error status is returned, this struct
611 * contains detailed information about the error, see wcserr_enable().
612 *
613 * double *tmpcrd
614 * (For internal use only.)
615 * int m_flag
616 * (For internal use only.)
617 * int m_naxis
618 * (For internal use only.)
619 * double *m_crpix
620 * (For internal use only.)
621 * double *m_pc
622 * (For internal use only.)
623 * double *m_cdelt
624 * (For internal use only.)
625 * struct disprm *m_dispre
626 * (For internal use only.)
627 * struct disprm *m_disseq
628 * (For internal use only.)
629 *
630 *
631 * Global variable: const char *lin_errmsg[] - Status return messages
632 * ------------------------------------------------------------------
633 * Error messages to match the status value returned from each function.
634 *
635 *===========================================================================*/
636
637 #ifndef WCSLIB_LIN
638 #define WCSLIB_LIN
639
640 #ifdef __cplusplus
641 extern "C" {
642 #endif
643
644
645 extern const char *lin_errmsg[];
646
647 enum lin_errmsg_enum {
648 LINERR_SUCCESS = 0, // Success.
649 LINERR_NULL_POINTER = 1, // Null linprm pointer passed.
650 LINERR_MEMORY = 2, // Memory allocation failed.
651 LINERR_SINGULAR_MTX = 3, // PCi_ja matrix is singular.
652 LINERR_DISTORT_INIT = 4, // Failed to initialise distortions.
653 LINERR_DISTORT = 5, // Distort error.
654 LINERR_DEDISTORT = 6 // De-distort error.
655 };
656
657 struct linprm {
658 // Initialization flag (see the prologue above).
659 //--------------------------------------------------------------------------
660 int flag; // Set to zero to force initialization.
661
662 // Parameters to be provided (see the prologue above).
663 //--------------------------------------------------------------------------
664 int naxis; // The number of axes, given by NAXIS.
665 double *crpix; // CRPIXja keywords for each pixel axis.
666 double *pc; // PCi_ja linear transformation matrix.
667 double *cdelt; // CDELTia keywords for each coord axis.
668 struct disprm *dispre; // Prior distortion parameters, if any.
669 struct disprm *disseq; // Sequent distortion parameters, if any.
670
671 // Information derived from the parameters supplied.
672 //--------------------------------------------------------------------------
673 double *piximg; // Product of CDELTia and PCi_ja matrices.
674 double *imgpix; // Inverse of the piximg matrix.
675 int i_naxis; // Dimension of piximg and imgpix.
676 int unity; // True if the PCi_ja matrix is unity.
677 int affine; // True if there are no distortions.
678 int simple; // True if unity and no distortions.
679
680 // Error handling, if enabled.
681 //--------------------------------------------------------------------------
682 struct wcserr *err;
683
684 // Private - the remainder are for internal use.
685 //--------------------------------------------------------------------------
686 double *tmpcrd;
687
688 int m_flag, m_naxis;
689 double *m_crpix, *m_pc, *m_cdelt;
690 struct disprm *m_dispre, *m_disseq;
691 };
692
693 // Size of the linprm struct in int units, used by the Fortran wrappers.
694 #define LINLEN (sizeof(struct linprm)/sizeof(int))
695
696
697 int linini(int alloc, int naxis, struct linprm *lin);
698
699 int lininit(int alloc, int naxis, struct linprm *lin, int ndpmax);
700
701 int lindis(int sequence, struct linprm *lin, struct disprm *dis);
702
703 int lindist(int sequence, struct linprm *lin, struct disprm *dis, int ndpmax);
704
705 int lincpy(int alloc, const struct linprm *linsrc, struct linprm *lindst);
706
707 int linfree(struct linprm *lin);
708
709 int linsize(const struct linprm *lin, int sizes[2]);
710
711 int linprt(const struct linprm *lin);
712
713 int linperr(const struct linprm *lin, const char *prefix);
714
715 int linset(struct linprm *lin);
716
717 int linp2x(struct linprm *lin, int ncoord, int nelem, const double pixcrd[],
718 double imgcrd[]);
719
720 int linx2p(struct linprm *lin, int ncoord, int nelem, const double imgcrd[],
721 double pixcrd[]);
722
723 int linwarp(struct linprm *lin, const double pixblc[], const double pixtrc[],
724 const double pixsamp[], int *nsamp,
725 double maxdis[], double *maxtot,
726 double avgdis[], double *avgtot,
727 double rmsdis[], double *rmstot);
728
729 int matinv(int n, const double mat[], double inv[]);
730
731
732 // Deprecated.
733 #define linini_errmsg lin_errmsg
734 #define lincpy_errmsg lin_errmsg
735 #define linfree_errmsg lin_errmsg
736 #define linprt_errmsg lin_errmsg
737 #define linset_errmsg lin_errmsg
738 #define linp2x_errmsg lin_errmsg
739 #define linx2p_errmsg lin_errmsg
740
741 #ifdef __cplusplus
742 }
743 #endif
744
745 #endif // WCSLIB_LIN
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.
linsize
int linsize(const struct linprm *lin, int sizes[2])
Compute the size of a linprm struct.
linx2p
int linx2p(struct linprm *lin, int ncoord, int nelem, const double imgcrd[], double pixcrd[])
World-to-pixel linear transformation.
linset
int linset(struct linprm *lin)
Setup routine for the linprm struct.
lin_errmsg_enum
lin_errmsg_enum
Definition: lin.h:647
LINERR_SUCCESS
@ LINERR_SUCCESS
Definition: lin.h:648
LINERR_MEMORY
@ LINERR_MEMORY
Definition: lin.h:650
LINERR_DEDISTORT
@ LINERR_DEDISTORT
Definition: lin.h:654
LINERR_DISTORT
@ LINERR_DISTORT
Definition: lin.h:653
LINERR_NULL_POINTER
@ LINERR_NULL_POINTER
Definition: lin.h:649
LINERR_DISTORT_INIT
@ LINERR_DISTORT_INIT
Definition: lin.h:652
LINERR_SINGULAR_MTX
@ LINERR_SINGULAR_MTX
Definition: lin.h:651
linperr
int linperr(const struct linprm *lin, const char *prefix)
Print error messages from a linprm struct.
lin_errmsg
const char * lin_errmsg[]
Status return messages.
linini
int linini(int alloc, int naxis, struct linprm *lin)
Default constructor for the linprm struct.
linprt
int linprt(const struct linprm *lin)
Print routine for the linprm struct.
lincpy
int lincpy(int alloc, const struct linprm *linsrc, struct linprm *lindst)
Copy routine for the linprm struct.
matinv
int matinv(int n, const double mat[], double inv[])
Matrix inversion.
lindist
int lindist(int sequence, struct linprm *lin, struct disprm *dis, int ndpmax)
Assign a distortion to a linprm struct.
lindis
int lindis(int sequence, struct linprm *lin, struct disprm *dis)
Assign a distortion to a linprm struct.
linp2x
int linp2x(struct linprm *lin, int ncoord, int nelem, const double pixcrd[], double imgcrd[])
Pixel-to-world linear transformation.
linfree
int linfree(struct linprm *lin)
Destructor for the linprm struct.
lininit
int lininit(int alloc, int naxis, struct linprm *lin, int ndpmax)
Default constructor for the linprm struct.
disprm
Distortion parameters.
Definition: dis.h:1093
disprm::naxis
int naxis
Definition: dis.h:1100
disprm::ndpmax
int ndpmax
Definition: dis.h:1104
disprm::maxdis
double * maxdis
Definition: dis.h:1106
linprm
Linear transformation parameters.
Definition: lin.h:657
linprm::m_crpix
double * m_crpix
Definition: lin.h:689
linprm::cdelt
double * cdelt
Definition: lin.h:667
linprm::imgpix
double * imgpix
Definition: lin.h:674
linprm::err
struct wcserr * err
Definition: lin.h:682
linprm::disseq
struct disprm * disseq
Definition: lin.h:669
linprm::crpix
double * crpix
Definition: lin.h:665
linprm::affine
int affine
Definition: lin.h:677
linprm::pc
double * pc
Definition: lin.h:666
linprm::i_naxis
int i_naxis
Definition: lin.h:675
linprm::m_cdelt
double * m_cdelt
Definition: lin.h:689
linprm::flag
int flag
Definition: lin.h:660
linprm::m_flag
int m_flag
Definition: lin.h:688
linprm::m_pc
double * m_pc
Definition: lin.h:689
linprm::dispre
struct disprm * dispre
Definition: lin.h:668
linprm::m_disseq
struct disprm * m_disseq
Definition: lin.h:690
linprm::m_dispre
struct disprm * m_dispre
Definition: lin.h:690
linprm::tmpcrd
double * tmpcrd
Definition: lin.h:686
linprm::naxis
int naxis
Definition: lin.h:664
linprm::piximg
double * piximg
Definition: lin.h:673
linprm::m_naxis
int m_naxis
Definition: lin.h:688
linprm::unity
int unity
Definition: lin.h:676
linprm::simple
int simple
Definition: lin.h:678
wcserr
Error message handling.
Definition: wcserr.h:243