00001 /** @file psSphereOps.h 00002 * 00003 * @brief Contains spherical rotation and offset operations 00004 * 00005 * @ingroup CoordinateTransform 00006 * 00007 * @author Robert DeSonia, MHPCC 00008 * @author David Robbins, MHPCC 00009 * 00010 * @version $Revision: 1.11 $ $Name: rel12 $ 00011 * @date $Date: 2006/02/14 00:09:27 $ 00012 * 00013 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00014 */ 00015 00016 #ifndef PS_SPHERE_H 00017 #define PS_SPHERE_H 00018 00019 /// @addtogroup CoordinateTransform 00020 /// @{ 00021 00022 #include "psTime.h" 00023 00024 /** Spherical Rotation Definition 00025 * 00026 * We need to be able to convert between ICRS, Galactic and Ecliptic 00027 * coordinates, and potentially between arbitrary spherical coordinate 00028 * systems. All of these basic spherical transformations represent rotations 00029 * of the spherical coordinate reference. 00030 * 00031 */ 00032 typedef struct 00033 { 00034 double q0; 00035 double q1; 00036 double q2; 00037 double q3; 00038 } 00039 psSphereRot; 00040 00041 /** Mode for Offset calculation between two sky positions 00042 * 00043 * @see psSphereGetOffset, psSphereSetOffset 00044 * 00045 */ 00046 typedef enum { 00047 PS_SPHERICAL, ///< offset corresponds to an angular offset 00048 PS_LINEAR ///< offset corresponds to a linear offset 00049 } psSphereOffsetMode; 00050 00051 /** The units of the offset 00052 * 00053 * @see psSphereGetOffset, psSphereSetOffset 00054 * 00055 */ 00056 typedef enum { 00057 PS_ARCSEC, ///< Arcseconds 00058 PS_ARCMIN, ///< Arcminutes 00059 PS_DEGREE, ///< Degrees 00060 PS_RADIAN ///< Radians 00061 } psSphereOffsetUnit; 00062 00063 00064 /** Allocator for psSphereRot 00065 * 00066 * @return psSphereRot* newly allocated psSphereRot 00067 */ 00068 00069 psSphereRot* psSphereRotAlloc( 00070 double alphaP, ///< north pole latitude 00071 double deltaP, ///< north pole longitude 00072 double phiP ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares). 00073 ); 00074 00075 /** Checks the type of a particular pointer. 00076 * 00077 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 00078 * 00079 * @return bool: True if the pointer matches a psSphereRot structure, false otherwise. 00080 */ 00081 bool psMemCheckSphereRot( 00082 psPtr ptr ///< the pointer whose type to check 00083 ); 00084 00085 00086 /** Allocator for psSphereRot given quaternions. 00087 * 00088 * Normalizes a given quaternion and returns the cooresponding newly allocated 00089 * psSphereRot object. 00090 * 00091 * @return psSphereRot* newly allocated psSphereRot 00092 */ 00093 psSphereRot* psSphereRotQuat( 00094 double q0, ///< q0 00095 double q1, ///< q1 00096 double q2, ///< q2 00097 double q3 ///< q3 00098 ); 00099 00100 /** Applies the psSphereTransform transform for a specified coordinate 00101 * 00102 * @return psSphere* resulting coordinate based on transform 00103 */ 00104 psSphere* psSphereRotApply( 00105 psSphere* out, ///< a psSphere to recycle. If NULL, a new one is generated. 00106 const psSphereRot* transform, ///< the transform to apply 00107 const psSphere* coord ///< the coordinate to apply the transform above.x 00108 ); 00109 00110 /** Combines two rotations. 00111 * 00112 * Combines two rotations to produce a single rotation which is the 00113 * equivalent of applying the first rotation and then the second. The output 00114 * rotation may be supplied, or will be allocated if NULL. 00115 * 00116 * @return psSphereRot* New psSphereRot that is the combination of the input psSphereRots 00117 */ 00118 psSphereRot* psSphereRotCombine( 00119 psSphereRot* out, ///< a psSphereRot to recycle or NULL 00120 const psSphereRot* rot1, ///< first rotation to combine 00121 const psSphereRot* rot2 ///< second rotation to combine 00122 ); 00123 00124 /** Returns the conjugate of a specified rotation. 00125 * 00126 * Stores the conjugate of a specified rotation in an existing psSphereRot* or creates a 00127 * new psSphereRot* if NULL. The conjugate of a rotation given in quaternions is -q0, 00128 * -q1, -q2, q3. 00129 * 00130 * @return psSphereRot* the Conjugate of the specified psSphereRot, in. 00131 */ 00132 psSphereRot* psSphereRotConjugate( 00133 psSphereRot *out, ///< a psSphereRot to recycle or NULL 00134 const psSphereRot *in ///< the psSphereRot from which to obtain the conjugate 00135 ); 00136 00137 /** Inverts the rotation. 00138 * 00139 * A given rotation is inverted by creating a psSphereRot using -phiP, -deltaP, -alphaP. 00140 * 00141 * @return psSphereRot* Inverted input psSphereRot 00142 */ 00143 psSphereRot* psSphereRotInvert( 00144 double alphaP, ///< north pole latitude 00145 double deltaP, ///< north pole longitude 00146 double phiP ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares). 00147 ); 00148 00149 /** Determines the offset (RA,Dec) on the sky between two positions. 00150 * 00151 * Both an offset mode and an offset unit may be defined. The mode may be 00152 * either PS_SPHERICAL, in which case the specified offset corresponds to an 00153 * offset in angles, or it may be PS_LINEAR, in which case the offset 00154 * corresponds to a linear offset in a local projection. The offset unit may 00155 * be in one of PS_ARCSEC, PS_ARCMIN, PS_DEGREE, and PS_RADIAN, which 00156 * specifies the units of the offset only. 00157 * 00158 * @return psSphere* the offset between position1 and position2 00159 */ 00160 psSphere* psSphereGetOffset( 00161 const psSphere* position1, ///< first position for calculating offset 00162 const psSphere* position2, ///< second position for calculating offset 00163 psSphereOffsetMode mode, ///< type of offset can be PS_SPHERICAL or PS_LINEAR 00164 psSphereOffsetUnit unit ///< specifies the units of offset only 00165 ); 00166 00167 /** Applies the given offset to a coordinate. 00168 * 00169 * Both an offset mode and an offset unit may be defined. The mode may be 00170 * either PS_SPHERICAL, in which case the specified offset corresponds to an 00171 * offset in angles, or it may be PS_LINEAR, in which case the offset 00172 * corresponds to a linear offset in a local projection. The offset unit may 00173 * be in one of PS_ARCSEC, PS_ARCMIN, PS_DEGREE, and PS_RADIAN, which 00174 * specifies the units of the offset only. 00175 * 00176 * @return psSphere* the original position with the given offset applied. 00177 */ 00178 psSphere* psSphereSetOffset( 00179 const psSphere* position, ///< coordinate of origin 00180 const psSphere* offset, ///< coordinate of offset to apply 00181 psSphereOffsetMode mode, ///< corresponds to an offset in angles or local projection 00182 psSphereOffsetUnit unit ///< specifies the units of offset only 00183 ); 00184 00185 /** Creates the appropriate transform for converting from ICRS to Ecliptic 00186 * coordinate systems. 00187 * 00188 * @return psSphereRot* transform for ICRS->Ecliptic coordinate systems 00189 */ 00190 psSphereRot* psSphereRotICRSToEcliptic( 00191 const psTime *time ///< the time for which the resulting transform will be valid 00192 ); 00193 00194 /** Creates the appropriate transform for converting from Ecliptic to ICRS 00195 * coordinate systems. 00196 * 00197 * @return psSphereRot* transform for Ecliptic->ICRS coordinate systems 00198 */ 00199 psSphereRot* psSphereRotEclipticToICRS( 00200 const psTime *time ///< the time for which the resulting transform will be valid 00201 ); 00202 00203 /** Creates the appropriate transform for converting from ICRS to Galactic 00204 * coordinate systems. 00205 * 00206 * @return psSphereRot* new sphere rotation for ICRS to Galactic transformations. 00207 */ 00208 psSphereRot* psSphereRotICRSToGalactic(void); 00209 00210 /** Creates the appropriate transform for converting from Galactic to ICRS 00211 * coordinate systems. 00212 * 00213 * @return psSphereRot* new sphere rotation for Galactic to ICRS transformations. 00214 */ 00215 psSphereRot* psSphereRotGalacticToICRS(void); 00216 00217 /// @} 00218 00219 #endif // #ifndef PS_SPHERE_H
1.4.4