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 *  @author GLG, MHPCC
00011 *
00012 *  @version $Revision: 1.1.1.1 $ $Name:  $
00013 *  @date $Date: 2005/06/15 21:08:12 $
00014 *
00015 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00016 */
00017 
00018 #ifndef PS_COORD_H
00019 #define PS_COORD_H
00020 
00021 #include "psType.h"
00022 #include "psImage.h"
00023 #include "psArray.h"
00024 #include "psList.h"
00025 #include "psFunctions.h"
00026 #include "psTime.h"
00027 
00028 /// @addtogroup CoordinateTransform
00029 /// @{
00030 
00031 /** Euclidiean Coordinate System.
00032  *
00033  *  Both detector and sky positions will be used extensively in the IPP. One
00034  *  coordinate system to be used is linear coordinates which conform to
00035  *  Euclidean geometry.
00036  *
00037  */
00038 typedef struct
00039 {
00040     double x;                   ///< x position
00041     double y;                   ///< y position
00042     double xErr;                ///< Error in x position
00043     double yErr;                ///< Error in y position
00044 }
00045 psPlane;
00046 
00047 /** Angular Coordinate System
00048  *
00049  *  Both detector and sky positions will be used extensively in the IPP. One
00050  *  coordinate system to be used is angular coordinates for which additional
00051  *  care must often be taken in comparison to a euclidiean coordinate system.
00052  *
00053  */
00054 typedef struct psSphere
00055 {
00056     double r;                   ///< RA
00057     double d;                   ///< Dec
00058     double rErr;                ///< Error in RA
00059     double dErr;                ///< Error in Dec
00060 }
00061 psSphere;
00062 
00063 /** 2D Polynomial Transform
00064  *
00065  *  A transform between coordinate systems that consists simply of two 2D
00066  *  polynomials to transform both components - the output coordinates depend
00067  *  only on the input coordinates and no other quantities of objects at those
00068  *  coordinates.
00069  *
00070  */
00071 typedef struct
00072 {
00073     psDPolynomial2D* x;         ///< 2D polynomial transform of X coordinates
00074     psDPolynomial2D* y;         ///< 2D polynomial transform of Y coordinates
00075 }
00076 psPlaneTransform;
00077 
00078 /** 4D Polynomial Transform
00079  *
00080  *  A transform between coordinate systems that consists of two 4D polynomials
00081  *  in which the output coordinates are also specified to be a function of the
00082  *  magnitude and color of the object with the given coordinates. This type of
00083  *  coordinate transformation is necessary to represent the (color-dependent)
00084  *  optical distortions caused by the atmosphere and camera optics, and the
00085  *  possibly effects of charge transfer inefficiency.
00086  *
00087  *  The lowest two terms are the x and y axis of the target system.  The higher
00088  *  two terms may represent magnitude and color terms.
00089  */
00090 typedef struct
00091 {
00092     psDPolynomial4D* x;         ///< 4D polynomial transform of X coordinates
00093     psDPolynomial4D* y;         ///< 4D polynomial transform of Y coordinates
00094 }
00095 psPlaneDistort;
00096 
00097 /** Spherical Transform Definition
00098  *
00099  *  We need to be able to convert between ICRS, Galactic and Ecliptic
00100  *  coordinates, and potentially between arbitrary spherical coordinate
00101  *  systems. All of these basic spherical transformations represent rotations
00102  *  of the spherical coordinate reference. We specify a general
00103  *  transformation function which takes a structure, psSphereTransform,
00104  *  defining the transformation between two spherical coordinate systems
00105  *
00106  */
00107 typedef struct
00108 {
00109     double alphaP;                    ///< Longitude of the target system pole in the source system
00110     double cosDeltaP;                 ///< Cosine of target pole latitude in the source system
00111     double sinDeltaP;                 ///< Sine of target pole latitude in the source system
00112     double phiP;                      ///< Longitude of the ascending node in the target system
00113 }
00114 psSphereTransform;
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 /** Mode for Offset calculation between two sky positions
00148  *
00149  *  @see  psSphereGetOffset, psSphereSetOffset
00150  *
00151  */
00152 typedef enum {
00153     PS_SPHERICAL,               ///< offset corresponds to an angular offset
00154     PS_LINEAR                   ///< offset corresponds to a linear offset
00155 } psSphereOffsetMode;
00156 
00157 /** The units of the offset
00158  *
00159  *  @see  psSphereGetOffset, psSphereSetOffset
00160  *
00161  */
00162 typedef enum {
00163     PS_ARCSEC,                  ///< Arcseconds
00164     PS_ARCMIN,                  ///< Arcminutes
00165     PS_DEGREE,                  ///< Degrees
00166     PS_RADIAN                   ///< Radians
00167 } psSphereOffsetUnit;
00168 
00169 /** Allocates a psPlane
00170  *
00171  *  @return psPlane*     resulting plane structure.
00172  */
00173 
00174 psPlane* psPlaneAlloc(void);
00175 
00176 /** Allocates a psSphere
00177  *
00178  *  @return psSphere*     resulting sphere structure.
00179  */
00180 
00181 psSphere* psSphereAlloc(void);
00182 
00183 
00184 /** Allocates a psPlaneTransform transform.
00185  *
00186  *  @return psPlaneTransform*     resulting plane transform
00187  */
00188 
00189 psPlaneTransform* psPlaneTransformAlloc(
00190     psS32 n1,  ///< The order of the x term in the transform.
00191     psS32 n2   ///< The order of the y term in the transform.
00192 );
00193 
00194 /** Applies the psPlaneTransform transform to a specified coordinate
00195  *
00196  *  @return psPlane*     resulting coordinate based on transform
00197  */
00198 psPlane* psPlaneTransformApply(
00199     psPlane* out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
00200     const psPlaneTransform* transform, ///< the transform to apply
00201     const psPlane* coords              ///< the coordinate to apply the transform above.
00202 );
00203 
00204 /** Allocates a psPlaneDistort transform.
00205  *
00206  *  @return psPlaneDistort*     resulting plane distort transform
00207  */
00208 
00209 psPlaneDistort* psPlaneDistortAlloc(
00210     psS32 n1,  ///< The order of the w term in the transform.
00211     psS32 n2,  ///< The order of the x term in the transform.
00212     psS32 n3,  ///< The order of the y term in the transform.
00213     psS32 n4   ///< The order of the z term in the transform.
00214 );
00215 
00216 
00217 /** Applies the psPlaneDistort transform to a specified coordinate
00218  *
00219  *  @return psPlane*     resulting coordinate based on transform
00220  */
00221 psPlane* psPlaneDistortApply(
00222     psPlane* out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
00223     const psPlaneDistort* transform,   ///< the transform to apply
00224     const psPlane* coords,             ///< the coordinate to apply the transform above.
00225     float term3,                       ///< third term -- maybe magnitude
00226     float term4                        ///< forth term -- maybe color
00227 );
00228 
00229 /** Allocator for psSphereTransform
00230  *
00231  *  @return psSphereTransform*         newly allocated struct
00232  */
00233 
00234 psSphereTransform* psSphereTransformAlloc(
00235     double alphaP,                      ///< north pole latitude
00236     double deltaP,                      ///< north pole longitude?
00237     double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
00238 );
00239 
00240 /** Applies the psSphereTransform transform for a specified coordinate
00241  *
00242  *  @return psSphere*      resulting coordinate based on transform
00243  */
00244 psSphere* psSphereTransformApply(
00245     psSphere* out,                     ///< a psSphere to recycle.  If NULL, a new one is generated.
00246     const psSphereTransform* transform,///< the transform to apply
00247     const psSphere* coord              ///< the coordinate to apply the transform above.x
00248 );
00249 
00250 /** Creates the appropriate transform for converting from ICRS to Ecliptic
00251  *  coordinate systems.
00252  *
00253  *  @return psSphereTransform*     transform for ICRS->Ecliptic coordinate systems
00254  */
00255 psSphereTransform* psSphereTransformICRSToEcliptic(
00256     psTime *time                        ///< the time for which the resulting transform will be valid
00257 );
00258 
00259 /** Creates the appropriate transform for converting from Ecliptic to ICRS
00260  *  coordinate systems.
00261  *
00262  *  @return psSphereTransform*     transform for Ecliptic->ICRS coordinate systems
00263  */
00264 psSphereTransform* psSphereTransformEclipticToICRS(
00265     psTime *time                        ///< the time for which the resulting transform will be valid
00266 );
00267 
00268 /** Creates the appropriate transform for converting from ICRS to Galactic
00269  *  coordinate systems.
00270  *
00271  */
00272 psSphereTransform* psSphereTransformICRSToGalactic(void);
00273 
00274 /** Creates the appropriate transform for converting from Galactic to ICRS
00275  *  coordinate systems.
00276  *
00277  */
00278 psSphereTransform* psSphereTransformGalacticToICRS(void);
00279 
00280 /** Allocates memory for a psProjection structure
00281  *
00282  *  @return psProjection*    psProjection structure
00283  */
00284 psProjection* psProjectionAlloc(
00285     psF64 R,                   ///< Right-ascension of projection center.
00286     psF64 D,                   ///< Declination of projection center.
00287     psF64 Xs,                  ///< Scale in x-dimension
00288     psF64 Ys,                  ///< Scale in y-dimension
00289     psProjectionType type
00290 );
00291 
00292 /** Projects a spherical coordinate to a linear coordinate system
00293  *
00294  *  @return psPlane*    projected coordinate
00295  */
00296 psPlane* psProject(
00297     const psSphere* coord,             ///< coordinate to project
00298     const psProjection* projection     ///< parameters of the projection
00299 );
00300 
00301 /** Reverse projection of a linear coordinate to a spherical coordinate system
00302  *
00303  *  @return psPlane*    projected coordinate
00304  */
00305 psSphere* psDeproject(
00306     const psPlane* coord,              ///< coordinate to project
00307     const psProjection* projection     ///< parameters of the projection
00308 );
00309 
00310 /** Determines the offset (RA,Dec) on the sky between two positions.
00311  *
00312  *  Both an offset mode and an offset unit may be defined. The mode may be
00313  *  either PS_SPHERICAL, in which case the specified offset corresponds to an
00314  *  offset in angles, or it may be PS_LINEAR, in which case the offset
00315  *  corresponds to a linear offset in a local projection. The offset unit may
00316  *  be in one of PS_ARCSEC, PS_ARCMIN, PS_DEGREE, and PS_RADIAN, which
00317  *  specifies the units of the offset only.
00318  *
00319  *  @return psSphere*        the offset between position1 and position2
00320  */
00321 psSphere* psSphereGetOffset(
00322     const psSphere* position1,         ///< first position for calculating offset
00323     const psSphere* position2,         ///< second position for calculating offset
00324     psSphereOffsetMode mode,           ///< type of offset can be PS_SPHERICAL or PS_LINEAR
00325     psSphereOffsetUnit unit            ///< specifies the units of offset only
00326 );
00327 
00328 /** Applies the given offset to a coordinate.
00329  *
00330  *  Both an offset mode and an offset unit may be defined. The mode may be
00331  *  either PS_SPHERICAL, in which case the specified offset corresponds to an
00332  *  offset in angles, or it may be PS_LINEAR, in which case the offset
00333  *  corresponds to a linear offset in a local projection. The offset unit may
00334  *  be in one of PS_ARCSEC, PS_ARCMIN, PS_DEGREE, and PS_RADIAN, which
00335  *  specifies the units of the offset only.
00336  *
00337  *  @return psSphere*              the original position with the given offset applied.
00338  */
00339 psSphere* psSphereSetOffset(
00340     const psSphere* position,          ///< coordinate of origin
00341     const psSphere* offset,            ///< coordinate of offset to apply
00342     psSphereOffsetMode mode,           ///< corresponds to an offset in angles or local projection
00343     psSphereOffsetUnit unit            ///< specifies the units of offset only
00344 );
00345 
00346 /** Generates the complete spherical rotation to account for precession
00347  *  between two times.  The equinoxes shall be Julian equinoxes.
00348  *
00349  *  @return psSphere* the resulting spherical rotation
00350  */
00351 psSphere* psSpherePrecess(
00352     psSphere *coords,                  ///< coordinates (modified in-place)
00353     const psTime *fromTime,            ///< equinox of coords input
00354     const psTime *toTime               ///< equinox of coords output
00355 );
00356 
00357 /** Takes a given transform and inverts it linearly if possible.
00358  *
00359  *  @return psPlaneTransform
00360  *  the linearly inverted transform
00361 */
00362 psPlaneTransform *p_psPlaneTransformLinearInvert(
00363     psPlaneTransform *transform        ///<    transform to invert
00364 );
00365 
00366 
00367 /** Takes a transform and tests whether or not it is a linear projection.
00368  *
00369  *  @return psS32
00370  *  the order of the projection
00371 */
00372 psS32 p_psIsProjectionLinear(
00373     psPlaneTransform *transform        ///<     transform to test for linearity
00374 );
00375 
00376 /** inverts a given transformation.
00377  *
00378  *  It may assume that the input transformation is one-to-one, and that the
00379  *  inverse transformation may be specified through using polynomials of the
00380  *  same type and order as the forward transformation. In the event that the
00381  *  input transformation is linear, an exact solution may be calculated;
00382  *  otherwise nSamples samples in each axis, covering the region specified by
00383  *  region shall be used as a grid to fit the best inverse transformation. The
00384  *  function shall return NULL if it was unable to generate the inverse
00385  *  transformation; otherwise it shall return the inverse transformation. In
00386  *  the event that out is NULL, a new psPlaneTransform shall be allocated and
00387  *  returned.
00388  *
00389  *  @return psPlaneTransform*  the resulting inverted transform
00390  */
00391 psPlaneTransform* psPlaneTransformInvert(
00392     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00393     const psPlaneTransform *in,        ///< transform to invert
00394     psRegion region,                   ///< region to fit for non-linear transform inversion
00395     int nSamples                       ///< number of samples in each axis for fit
00396 );
00397 
00398 /** Creates a single transformation that has the effect of performing trans1
00399  *  followed by trans2.
00400  *
00401  *  psPlaneTransformCombine takes two transformations (trans1 and trans2) and
00402  *  returns a single transformation that has the effect of performing trans1
00403  *  followed by trans2. In the event that the input transformation is linear,
00404  *  an exact solution may be calculated; otherwise nSamples samples in each
00405  *  axis, covering the region specified by region shall be used as a grid to
00406  *  fit the best inverse transformation. The function shall return NULL if it
00407  *  was unable to generate the transformation; otherwise it shall return the
00408  *  transformation.
00409  *
00410  *  @return psPlaneTransform*    resulting transformation
00411  */
00412 psPlaneTransform* psPlaneTransformCombine(
00413     psPlaneTransform *out,             ///< a transform to recycle, or NULL if one is to be created.
00414     const psPlaneTransform *trans1,    ///< first transform to combine
00415     const psPlaneTransform *trans2,    ///< first transform to combine
00416     psRegion region,                   ///< region to cover (for non-linear transforms)
00417     int nSamples                       ///< number of samples on each axis (for non-linear transforms)
00418 );
00419 
00420 
00421 /** takes two arrays containing matched coordinates and returns the
00422  *  best-fitting transformation.
00423  *
00424  *  psPlaneTransformFit takes two arrays containing matched coordinates (i.e.,
00425  *  coordinates in the source array correspond to the coordinates in the dest
00426  *  array) and returns the best-fitting transformation. The source and dest
00427  *  will contain psCoords. In the event that the number of coordinates in each
00428  *  is not identical, the function shall generate a warning, and extra
00429  *  coordinates in the longer of the two shall be ignored. The trans transform
00430  *  may not be NULL, since it specifies the desired order, polynomial type and
00431  *  any polynomial terms to mask. nRejIter rejection iterations shall be
00432  *  performed, wherein coordinates lying more than sigmaClip standard
00433  *  deviations from the fit shall be rejected.
00434  *
00435  *  @return bool        TRUE if successful, otherwise FALSE.
00436  */
00437 bool psPlaneTransformFit(
00438     psPlaneTransform *trans,
00439     const psArray *source,
00440     const psArray *dest,
00441     int nRejIter,
00442     float sigmaClip
00443 );
00444 //XXX: need to add doxygen comments on the parameters above. -rdd
00445 
00446 /// @}
00447 
00448 #endif // #ifndef PS_COORD_H

Generated on Wed Jun 15 11:00:56 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1