Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psCoord.h

Go to the documentation of this file.
00001 /** @file  psCoord.h
00002  *
00003  *  @brief Contains basic coordinate transformation definitions and operations
00004  *
00005  *  This file defines the basic types for astronomical coordinate
00006  *  transformation
00007  *
00008  *  @ingroup CoordinateTransform
00009  *
00010  *
00011  *  @author GLG, MHPCC
00012  *
00013  *  @version $Revision: 1.48 $ $Name: rel9_0 $
00014  *  @date $Date: 2005/11/30 02:00:00 $
00015  *
00016  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00017  */
00018 
00019 #ifndef PS_COORD_H
00020 #define PS_COORD_H
00021 
00022 #include "psType.h"
00023 #include "psImage.h"
00024 #include "psArray.h"
00025 #include "psList.h"
00026 #include "psPolynomial.h"
00027 //#include "psTime.h"
00028 
00029 /// @addtogroup CoordinateTransform
00030 /// @{
00031 
00032 /** Euclidiean Coordinate System.
00033  *
00034  *  Both detector and sky positions will be used extensively in the IPP. One
00035  *  coordinate system to be used is linear coordinates which conform to
00036  *  Euclidean geometry.
00037  *
00038  */
00039 typedef struct
00040 {
00041     double x;                          ///< x position
00042     double y;                          ///< y position
00043     double xErr;                       ///< Error in x position
00044     double yErr;                       ///< Error in y position
00045 }
00046 psPlane;
00047 
00048 /** Angular Coordinate System
00049  *
00050  *  Both detector and sky positions will be used extensively in the IPP. One
00051  *  coordinate system to be used is angular coordinates for which additional
00052  *  care must often be taken in comparison to a euclidiean coordinate system.
00053  *
00054  */
00055 typedef struct
00056 {
00057     double r;                          ///< RA
00058     double d;                          ///< Dec
00059     double rErr;                       ///< Error in RA
00060     double dErr;                       ///< Error in Dec
00061 }
00062 psSphere;
00063 
00064 /** 3-Dimensional Euclidean Coordinate System
00065  *
00066  *  Both detector and sky positions will be used extensively in the IPP. One
00067  *  coordinate system to be used is cubic coordinates for which additional
00068  *  care must often be taken in comparison to an angular coordinate system.
00069  *
00070  */
00071 typedef struct
00072 {
00073     double x;                          ///< cos (DEC) cos (RA)
00074     double y;                          ///< cos (DEC) sin (RA)
00075     double z;                          ///< sin (DEC)
00076     double xErr;                       ///< Error in x
00077     double yErr;                       ///< Error in y
00078     double zErr;                       ///< Error in z
00079 }
00080 psCube;
00081 
00082 /** 2D Polynomial Transform
00083  *
00084  *  A transform between coordinate systems that consists simply of two 2D
00085  *  polynomials to transform both components - the output coordinates depend
00086  *  only on the input coordinates and no other quantities of objects at those
00087  *  coordinates.
00088  *
00089  */
00090 typedef struct
00091 {
00092     psPolynomial2D* x;                 ///< 2D polynomial transform of X coordinates
00093     psPolynomial2D* y;                 ///< 2D polynomial transform of Y coordinates
00094 }
00095 psPlaneTransform;
00096 
00097 /** 4D Polynomial Transform
00098  *
00099  *  A transform between coordinate systems that consists of two 4D polynomials
00100  *  in which the output coordinates are also specified to be a function of the
00101  *  magnitude and color of the object with the given coordinates. This type of
00102  *  coordinate transformation is necessary to represent the (color-dependent)
00103  *  optical distortions caused by the atmosphere and camera optics, and the
00104  *  possibly effects of charge transfer inefficiency.
00105  *
00106  *  The lowest two terms are the x and y axis of the target system.  The higher
00107  *  two terms may represent magnitude and color terms.
00108  */
00109 typedef struct
00110 {
00111     psPolynomial4D* x;                 ///< 4D polynomial transform of X coordinates
00112     psPolynomial4D* y;                 ///< 4D polynomial transform of Y coordinates
00113 }
00114 psPlaneDistort;
00115 
00116 /** Projection type for projection/deprojection
00117  *
00118  *  @see psProject, psDeproject
00119  *
00120  */
00121 typedef enum {
00122     PS_PROJ_TAN,                       ///< Tangent projection
00123     PS_PROJ_SIN,                       ///< Sine projection
00124     PS_PROJ_AIT,                       ///< Aitoff projection
00125     PS_PROJ_PAR,                       ///< Par projection
00126     //    PS_PROJ_GLS,                ///< GLS projection
00127     //    PS_PROJ_CAR,                ///< CAR projection
00128     //    PS_PROJ_MER,                ///< MER projection
00129     PS_PROJ_NTYPE                      ///< Number of types; must be last.
00130 } psProjectionType;
00131 
00132 /** Parameter set for projection/deprojection
00133  *
00134  *  @see psProject, psDeproject
00135  *
00136  */
00137 typedef struct
00138 {
00139     double R;                          ///< Coordinates of projection center
00140     double D;                          ///< Coordinates of projection center
00141     double Xs;                         ///< plate-scale in X direction
00142     double Ys;                         ///< plate-scale in Y direction
00143     psProjectionType type;             ///< Projection type
00144 }
00145 psProjection;
00146 
00147 /** Allocates a psPlane
00148  *
00149  *  @return psPlane*     resulting plane structure.
00150  */
00151 psPlane* psPlaneAlloc(void);
00152 
00153 /** Allocates a psSphere
00154  *
00155  *  @return psSphere*     resulting sphere structure.
00156  */
00157 psSphere* psSphereAlloc(void);
00158 
00159 /** Allocates a psCube
00160  *
00161  *  @return psCube*     resulting cubic structure.
00162  */
00163 psCube* psCubeAlloc(void);
00164 
00165 /** Allocates a psPlaneTransform transform.
00166  *
00167  *  @return psPlaneTransform*     resulting plane transform
00168  */
00169 
00170 psPlaneTransform* psPlaneTransformAlloc(
00171     int n1,                            ///< The order of the x term in the transform.
00172     int n2                             ///< The order of the y term in the transform.
00173 );
00174 
00175 /** Applies the psPlaneTransform transform to a specified coordinate
00176  *
00177  *  @return psPlane*     resulting coordinate based on transform
00178  */
00179 psPlane* psPlaneTransformApply(
00180     psPlane* out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
00181     const psPlaneTransform* transform, ///< the transform to apply
00182     const psPlane* coords              ///< the coordinate to apply the transform above.
00183 );
00184 
00185 /** Allocates a psPlaneDistort transform.
00186  *
00187  *  @return psPlaneDistort*     resulting plane distort transform
00188  */
00189 
00190 psPlaneDistort* psPlaneDistortAlloc(
00191     int n1,                            ///< The order of the w term in the transform.
00192     int n2,                            ///< The order of the x term in the transform.
00193     int n3,                            ///< The order of the y term in the transform.
00194     int n4                             ///< The order of the z term in the transform.
00195 );
00196 
00197 
00198 /** Applies the psPlaneDistort transform to a specified coordinate
00199  *
00200  *  @return psPlane*     resulting coordinate based on transform
00201  */
00202 psPlane* psPlaneDistortApply(
00203     psPlane* out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
00204     const psPlaneDistort* distort,     ///< the transform to apply
00205     const psPlane* coords,             ///< the coordinate to apply the transform above.
00206     float mag,                         ///< third term -- maybe magnitude
00207     float color                        ///< forth term -- maybe color
00208 );
00209 
00210 /** Allocates memory for a psProjection structure
00211  *
00212  *  @return psProjection*    psProjection structure
00213  */
00214 psProjection* psProjectionAlloc(
00215     double R,                          ///< Right-ascension of projection center.
00216     double D,                          ///< Declination of projection center.
00217     double Xs,                         ///< Scale in x-dimension
00218     double Ys,                         ///< Scale in y-dimension
00219     psProjectionType type
00220 );
00221 
00222 /** Checks the type of a particular pointer.
00223  *
00224  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00225  *
00226  *  @return bool:       True if the pointer matches a psPlane structure, false otherwise.
00227  */
00228 bool psMemCheckPlane(
00229     psPtr ptr                          ///< the pointer whose type to check
00230 );
00231 
00232 /** Checks the type of a particular pointer.
00233  *
00234  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00235  *
00236  *  @return bool:       True if the pointer matches a psSphere structure, false otherwise.
00237  */
00238 bool psMemCheckSphere(
00239     psPtr ptr                          ///< the pointer whose type to check
00240 );
00241 
00242 /** Checks the type of a particular pointer.
00243  *
00244  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00245  *
00246  *  @return bool:       True if the pointer matches a psCube structure, false otherwise.
00247  */
00248 bool psMemCheckCube(
00249     psPtr ptr                          ///< the pointer whose type to check
00250 );
00251 
00252 /** Checks the type of a particular pointer.
00253  *
00254  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00255  *
00256  *  @return bool:       True if the pointer matches a psPlaneTransform structure, false otherwise.
00257  */
00258 bool psMemCheckPlaneTransform(
00259     psPtr ptr                          ///< the pointer whose type to check
00260 );
00261 
00262 /** Checks the type of a particular pointer.
00263  *
00264  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00265  *
00266  *  @return bool:       True if the pointer matches a psPlaneDistort structure, false otherwise.
00267  */
00268 bool psMemCheckPlaneDistort(
00269     psPtr ptr                          ///< the pointer whose type to check
00270 );
00271 
00272 /** Checks the type of a particular pointer.
00273  *
00274  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00275  *
00276  *  @return bool:       True if the pointer matches a psProjection structure, false otherwise.
00277  */
00278 bool psMemCheckProjection(
00279     psPtr ptr                          ///< the pointer whose type to check
00280 );
00281 
00282 
00283 /** Projects a spherical coordinate to a linear coordinate system
00284  *
00285  *  @return psPlane*    projected coordinate
00286  */
00287 psPlane* psProject(
00288     const psSphere* coord,             ///< coordinate to project
00289     const psProjection* projection     ///< parameters of the projection
00290 );
00291 
00292 psPlane* p_psProject(
00293     psPlane *out,
00294     const psSphere* coord,             ///< coordinate to project
00295     const psProjection* projection     ///< parameters of the projection
00296 );
00297 
00298 /** Reverse projection of a linear coordinate to a spherical coordinate system
00299  *
00300  *  @return psPlane*    projected coordinate
00301  */
00302 psSphere* psDeproject(
00303     const psPlane* coord,              ///< coordinate to project
00304     const psProjection* projection     ///< parameters of the projection
00305 );
00306 
00307 /** Private reverse projection of a linear coordinate to a spherical coordinate system
00308  *
00309  *  @return psPlane*    projected coordinate
00310  */
00311 psSphere* p_psDeproject(
00312     psSphere *outSphere,
00313     const psPlane* coord,              ///< coordinate to project
00314     const psProjection* projection     ///< parameters of the projection
00315 );
00316 
00317 /** Takes a given transform and inverts it linearly if possible.
00318  *
00319  *  @return psPlaneTransform
00320  *  the linearly inverted transform
00321 */
00322 psPlaneTransform *p_psPlaneTransformLinearInvert(
00323     psPlaneTransform *transform        ///< transform to invert
00324 );
00325 psPlaneTransform *p_psPlaneTransformLinearInvert_MHPCC(
00326     psPlaneTransform *transform        ///< transform to invert
00327 );
00328 
00329 
00330 /** Takes a transform and tests whether or not it is a linear projection.
00331  *
00332  *  @return psS32
00333  *  the order of the projection
00334 */
00335 psBool p_psIsProjectionLinear(
00336     psPlaneTransform *transform        ///< transform to test for linearity
00337 );
00338 
00339 
00340 /** inverts a given transformation.
00341  *
00342  *  It may assume that the input transformation is one-to-one, and that the
00343  *  inverse transformation may be specified through using polynomials of the
00344  *  same type and order as the forward transformation. In the event that the
00345  *  input transformation is linear, an exact solution may be calculated;
00346  *  otherwise nSamples samples in each axis, covering the region specified by
00347  *  region shall be used as a grid to fit the best inverse transformation. The
00348  *  function shall return NULL if it was unable to generate the inverse
00349  *  transformation; otherwise it shall return the inverse transformation. In
00350  *  the event that out is NULL, a new psPlaneTransform shall be allocated and
00351  *  returned.
00352  *
00353  *  @return psPlaneTransform*  the resulting inverted transform
00354  */
00355 psPlaneTransform* psPlaneTransformInvert(
00356     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00357     const psPlaneTransform *in,        ///< transform to invert
00358     psRegion region,                   ///< region to fit for non-linear transform inversion
00359     int nSamples                       ///< number of samples in each axis for fit
00360 );
00361 
00362 /** Creates a single transformation that has the effect of performing trans1
00363  *  followed by trans2.
00364  *
00365  *  psPlaneTransformCombine takes two transformations (trans1 and trans2) and
00366  *  returns a single transformation that has the effect of performing trans1
00367  *  followed by trans2. In the event that the input transformation is linear,
00368  *  an exact solution may be calculated; otherwise nSamples samples in each
00369  *  axis, covering the region specified by region shall be used as a grid to
00370  *  fit the best inverse transformation. The function shall return NULL if it
00371  *  was unable to generate the transformation; otherwise it shall return the
00372  *  transformation.
00373  *
00374  *  @return psPlaneTransform*    resulting transformation
00375  */
00376 psPlaneTransform* psPlaneTransformCombine(
00377     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00378     const psPlaneTransform *trans1,    ///< first transform to combine
00379     const psPlaneTransform *trans2,    ///< first transform to combine
00380     psRegion region,                   ///< region to cover (for non-linear transforms)
00381     int nSamples                       ///< number of samples on each axis (for non-linear transforms)
00382 );
00383 
00384 
00385 /** takes two arrays containing matched coordinates and returns the
00386  *  best-fitting transformation.
00387  *
00388  *  psPlaneTransformFit takes two arrays containing matched coordinates (i.e.,
00389  *  coordinates in the source array correspond to the coordinates in the dest
00390  *  array) and returns the best-fitting transformation. The source and dest
00391  *  will contain psCoords. In the event that the number of coordinates in each
00392  *  is not identical, the function shall generate a warning, and extra
00393  *  coordinates in the longer of the two shall be ignored. The trans transform
00394  *  may not be NULL, since it specifies the desired order, polynomial type and
00395  *  any polynomial terms to mask. nRejIter rejection iterations shall be
00396  *  performed, wherein coordinates lying more than sigmaClip standard
00397  *  deviations from the fit shall be rejected.
00398  *
00399  *  @return bool        TRUE if successful, otherwise FALSE.
00400  */
00401 bool psPlaneTransformFit(
00402     psPlaneTransform *trans,           ///< desired order, polynomial type, & polynomial mask terms
00403     const psArray *source,             ///< coordinates matching those in dest
00404     const psArray *dest,               ///< coordinates matching those in source
00405     int nRejIter,                      ///< number of rejection iterations to be performed
00406     float sigmaClip                    ///< coordinates above this number of standard deviations will be rejected
00407 );
00408 //XXX: need to add doxygen comments on the parameters above. -rdd
00409 
00410 /** Converts from a 3-dimensional coordinate system to an angular coordinate system.
00411  *
00412  *  @return psSphere*       The former psCube in terms of a psSphere.
00413  */
00414 psSphere *psCubeToSphere(
00415     const psCube *cube                 ///< psCube to convert
00416 );
00417 
00418 /** Converts from an angular coordinate system to a 3-dimensional coordinate system.
00419  *
00420  *  @return psCube*         The former psSphere in terms of a psCube.
00421  */
00422 psCube *psSphereToCube(
00423     const psSphere *sphere             ///< psSphere to convert
00424 );
00425 
00426 
00427 /** Calculates the derivative of the specified psPlaneTransform with respect to x and y.
00428  *
00429  *  @return psPlane*         The derivative.
00430  */
00431 psPlane *psPlaneTransformDeriv(
00432     psPlane *out,
00433     const psPlaneTransform *transformation,
00434     const psPlane *coord
00435 );
00436 
00437 /// @}
00438 
00439 #endif // #ifndef PS_COORD_H

Generated on Tue Dec 6 17:18:42 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2