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