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