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.1.1.1 $ $Name:  $
00014 *  @date $Date: 2005/09/14 20:42:48 $
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 /** Reverse projection of a linear coordinate to a spherical coordinate system
00293  *
00294  *  @return psPlane*    projected coordinate
00295  */
00296 psSphere* psDeproject(
00297     const psPlane* coord,              ///< coordinate to project
00298     const psProjection* projection     ///< parameters of the projection
00299 );
00300 
00301 /** Takes a given transform and inverts it linearly if possible.
00302  *
00303  *  @return psPlaneTransform
00304  *  the linearly inverted transform
00305 */
00306 psPlaneTransform *p_psPlaneTransformLinearInvert(
00307     psPlaneTransform *transform        ///< transform to invert
00308 );
00309 
00310 
00311 /** Takes a transform and tests whether or not it is a linear projection.
00312  *
00313  *  @return psS32
00314  *  the order of the projection
00315 */
00316 psS32 p_psIsProjectionLinear(
00317     psPlaneTransform *transform        ///< transform to test for linearity
00318 );
00319 
00320 /** inverts a given transformation.
00321  *
00322  *  It may assume that the input transformation is one-to-one, and that the
00323  *  inverse transformation may be specified through using polynomials of the
00324  *  same type and order as the forward transformation. In the event that the
00325  *  input transformation is linear, an exact solution may be calculated;
00326  *  otherwise nSamples samples in each axis, covering the region specified by
00327  *  region shall be used as a grid to fit the best inverse transformation. The
00328  *  function shall return NULL if it was unable to generate the inverse
00329  *  transformation; otherwise it shall return the inverse transformation. In
00330  *  the event that out is NULL, a new psPlaneTransform shall be allocated and
00331  *  returned.
00332  *
00333  *  @return psPlaneTransform*  the resulting inverted transform
00334  */
00335 psPlaneTransform* psPlaneTransformInvert(
00336     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00337     const psPlaneTransform *in,        ///< transform to invert
00338     psRegion region,                   ///< region to fit for non-linear transform inversion
00339     int nSamples                       ///< number of samples in each axis for fit
00340 );
00341 
00342 /** Creates a single transformation that has the effect of performing trans1
00343  *  followed by trans2.
00344  *
00345  *  psPlaneTransformCombine takes two transformations (trans1 and trans2) and
00346  *  returns a single transformation that has the effect of performing trans1
00347  *  followed by trans2. In the event that the input transformation is linear,
00348  *  an exact solution may be calculated; otherwise nSamples samples in each
00349  *  axis, covering the region specified by region shall be used as a grid to
00350  *  fit the best inverse transformation. The function shall return NULL if it
00351  *  was unable to generate the transformation; otherwise it shall return the
00352  *  transformation.
00353  *
00354  *  @return psPlaneTransform*    resulting transformation
00355  */
00356 psPlaneTransform* psPlaneTransformCombine(
00357     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00358     const psPlaneTransform *trans1,    ///< first transform to combine
00359     const psPlaneTransform *trans2,    ///< first transform to combine
00360     psRegion region,                   ///< region to cover (for non-linear transforms)
00361     int nSamples                       ///< number of samples on each axis (for non-linear transforms)
00362 );
00363 
00364 
00365 /** takes two arrays containing matched coordinates and returns the
00366  *  best-fitting transformation.
00367  *
00368  *  psPlaneTransformFit takes two arrays containing matched coordinates (i.e.,
00369  *  coordinates in the source array correspond to the coordinates in the dest
00370  *  array) and returns the best-fitting transformation. The source and dest
00371  *  will contain psCoords. In the event that the number of coordinates in each
00372  *  is not identical, the function shall generate a warning, and extra
00373  *  coordinates in the longer of the two shall be ignored. The trans transform
00374  *  may not be NULL, since it specifies the desired order, polynomial type and
00375  *  any polynomial terms to mask. nRejIter rejection iterations shall be
00376  *  performed, wherein coordinates lying more than sigmaClip standard
00377  *  deviations from the fit shall be rejected.
00378  *
00379  *  @return bool        TRUE if successful, otherwise FALSE.
00380  */
00381 bool psPlaneTransformFit(
00382     psPlaneTransform *trans,           ///< desired order, polynomial type, & polynomial mask terms
00383     const psArray *source,             ///< coordinates matching those in dest
00384     const psArray *dest,               ///< coordinates matching those in source
00385     int nRejIter,                      ///< number of rejection iterations to be performed
00386     float sigmaClip                    ///< coordinates above this number of standard deviations will be rejected
00387 );
00388 //XXX: need to add doxygen comments on the parameters above. -rdd
00389 
00390 /** Converts from a 3-dimensional coordinate system to an angular coordinate system.
00391  *
00392  *  @return psSphere*       The former psCube in terms of a psSphere.
00393  */
00394 psSphere *psCubeToSphere(
00395     const psCube *cube                 ///< psCube to convert
00396 );
00397 
00398 /** Converts from an angular coordinate system to a 3-dimensional coordinate system.
00399  *
00400  *  @return psCube*         The former psSphere in terms of a psCube.
00401  */
00402 psCube *psSphereToCube(
00403     const psSphere *sphere             ///< psSphere to convert
00404 );
00405 
00406 
00407 /** Calculates the derivative of the specified psPlaneTransform with respect to x and y.
00408  *
00409  *  @return psPlane*         The derivative.
00410  */
00411 psPlane *psPlaneTransformDeriv(
00412     psPlane *out,
00413     const psPlaneTransform *transformation,
00414     const psPlane *coord
00415 );
00416 
00417 /// @}
00418 
00419 #endif // #ifndef PS_COORD_H

Generated on Wed Sep 14 10:42:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2