WCSLIB: lin.h Source File

WCSLIB 7.4

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