WCSLIB 5.19.1

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