Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/people/mcalabre/WCS/wcslib/structlinprm.html
Дата изменения: Unknown
Дата индексирования: Sun Apr 10 23:50:46 2016
Кодировка:

Поисковые слова: annular solar eclipse
WCSLIB: linprm Struct Reference
WCSLIB  5.15
Data Fields
linprm Struct Reference

Linear transformation parameters. More...

#include <lin.h>

Data Fields

int flag
 
int naxis
 
double * crpix
 
double * pc
 
double * cdelt
 
struct disprmdispre
 
struct disprmdisseq
 
double * piximg
 
double * imgpix
 
int i_naxis
 
int unity
 
int affine
 
int simple
 
struct wcserrerr
 
double * tmpcrd
 
int m_flag
 
int m_naxis
 
double * m_crpix
 
double * m_pc
 
double * m_cdelt
 
struct disprmm_dispre
 
struct disprmm_disseq
 

Detailed Description

The linprm struct contains all of the information required to perform a linear transformation. It consists of certain members that must be set by the user (given) and others that are set by the WCSLIB routines (returned).

Field Documentation

int linprm::flag

(Given and returned) This flag must be set to zero whenever any of the following members of the linprm struct are set or modified:

This signals the initialization routine, linset(), to recompute the returned members of the linprm struct. linset() will reset flag to indicate that this has been done.

PLEASE NOTE: flag should be set to -1 when linini() is called for the first time for a particular linprm struct in order to initialize memory management. It must ONLY be used on the first initialization otherwise memory leaks may result.

int linprm::naxis

(Given or returned) Number of pixel and world coordinate elements.

If linini() is used to initialize the linprm struct (as would normally be the case) then it will set naxis from the value passed to it as a function argument. The user should not subsequently modify it.

double * linprm::crpix

(Given) Pointer to the first element of an array of double containing the coordinate reference pixel, CRPIXja.

It is not necessary to reset the linprm struct (via linset()) when linprm::crpix is changed.

double * linprm::pc

(Given) Pointer to the first element of the PCi_ja (pixel coordinate) transformation matrix. The expected order is

struct linprm lin;
lin.pc = {PC1_1, PC1_2, PC2_1, PC2_2};

This may be constructed conveniently from a 2-D array via

double m[2][2] = {{PC1_1, PC1_2},
{PC2_1, PC2_2}};

which is equivalent to

double m[2][2];
m[0][0] = PC1_1;
m[0][1] = PC1_2;
m[1][0] = PC2_1;
m[1][1] = PC2_2;

The storage order for this 2-D array is the same as for the 1-D array, whence

lin.pc = *m;

would be legitimate.

double * linprm::cdelt

(Given) Pointer to the first element of an array of double containing the coordinate increments, CDELTia.

struct disprm * linprm::dispre

(Given) Pointer to a disprm struct holding parameters for prior distortion functions, or a null (0x0) pointer if there are none.

Function lindis() may be used to assign a disprm pointer to a linprm struct, allowing it to take control of any memory allocated for it, as in the following example:

void add_distortion(struct linprm *lin)
{
struct disprm *dispre;
dispre = malloc(sizeof(struct disprm);
dispre->flag = -1;
lindis(1, lin, dispre);
:
(Set up dispre.)
:
return;
}

Here, after the distortion function parameters etc. are copied into dispre, dispre is assigned using lindis() which takes control of the allocated memory. It will be free'd later when linfree() is invoked on the linprm struct.

Consider also the following erroneous code:

void bad_code(struct linprm *lin)
{
struct disprm dispre;
dispre.flag = -1;
lindis(1, lin, &dispre); // WRONG.
:
return;
}

Here, dispre is declared as a struct, rather than a pointer. When the function returns, dispre will go out of scope and its memory will most likely be reused, thereby trashing its contents. Later, a segfault will occur when linfree() tries to free dispre's stale address.

struct disprm * linprm::disseq

(Given) Pointer to a disprm struct holding parameters for sequent distortion functions, or a null (0x0) pointer if there are none.

Refer to the comments and examples given for disprm::dispre.

double * linprm::piximg

(Returned) Pointer to the first element of the matrix containing the product of the CDELTia diagonal matrix and the PCi_ja matrix.

double * linprm::imgpix

(Returned) Pointer to the first element of the inverse of the linprm::piximg matrix.

int linprm::i_naxis

(Returned) The dimension of linprm::piximg and linprm::imgpix (normally equal to naxis).

int linprm::unity

(Returned) True if the linear transformation matrix is unity.

int linprm::affine

(Returned) True if there are no distortions.

int linprm::simple

(Returned) True if unity and no distortions.

struct wcserr * linprm::err

(Returned) If enabled, when an error status is returned, this struct contains detailed information about the error, see wcserr_enable().

double * linprm::tmpcrd

(For internal use only.)

int linprm::m_flag

(For internal use only.)

int linprm::m_naxis

(For internal use only.)

double * linprm::m_crpix

(For internal use only.)

double * linprm::m_pc

(For internal use only.)

double * linprm::m_cdelt

(For internal use only.)

struct disprm * linprm::m_dispre

(For internal use only.)

struct disprm * linprm::m_disseq

(For internal use only.)