00001 /*============================================================================ 00002 00003 WCSLIB 4.4 - an implementation of the FITS WCS standard. 00004 Copyright (C) 1995-2009, Mark Calabretta 00005 00006 This file is part of WCSLIB. 00007 00008 WCSLIB is free software: you can redistribute it and/or modify it under the 00009 terms of the GNU Lesser General Public License as published by the Free 00010 Software Foundation, either version 3 of the License, or (at your option) 00011 any later version. 00012 00013 WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY 00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00016 more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with WCSLIB. If not, see <http://www.gnu.org/licenses/>. 00020 00021 Correspondence concerning WCSLIB may be directed to: 00022 Internet email: mcalabre@atnf.csiro.au 00023 Postal address: Dr. Mark Calabretta 00024 Australia Telescope National Facility, CSIRO 00025 PO Box 76 00026 Epping NSW 1710 00027 AUSTRALIA 00028 00029 Author: Mark Calabretta, Australia Telescope National Facility 00030 http://www.atnf.csiro.au/~mcalabre/index.html 00031 $Id: sph_8h-source.html,v 1.1 2009/09/14 20:25:24 irby Exp $ 00032 *============================================================================= 00033 * 00034 * WCSLIB 4.4 - C routines that implement the spherical coordinate 00035 * transformations used by the FITS World Coordinate System (WCS) standard. 00036 * Refer to 00037 * 00038 * "Representations of world coordinates in FITS", 00039 * Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (Paper I) 00040 * 00041 * "Representations of celestial coordinates in FITS", 00042 * Calabretta, M.R., & Greisen, E.W. 2002, A&A, 395, 1077 (Paper II) 00043 * 00044 * Refer to the README file provided with WCSLIB for an overview of the 00045 * library. 00046 * 00047 * 00048 * Summary of the sph routines 00049 * --------------------------- 00050 * The WCS spherical coordinate transformations are implemented via separate 00051 * functions, sphx2s() and sphs2x(), for the transformation in each direction. 00052 * 00053 * A utility function, sphdpa(), uses these to compute the angular distance and 00054 * position angle from a given point on the sky to a number of other points. 00055 * 00056 * 00057 * sphx2s() - Rotation in the pixel-to-world direction 00058 * --------------------------------------------------- 00059 * sphx2s() transforms native coordinates of a projection to celestial 00060 * coordinates. 00061 * 00062 * Given: 00063 * eul const double[5] 00064 * Euler angles for the transformation: 00065 * 0: Celestial longitude of the native pole [deg]. 00066 * 1: Celestial colatitude of the native pole, or 00067 * native colatitude of the celestial pole [deg]. 00068 * 2: Native longitude of the celestial pole [deg]. 00069 * 3: cos(eul[1]) 00070 * 4: sin(eul[1]) 00071 * nphi, 00072 * ntheta int Vector lengths. 00073 * spt,sxy int Vector strides. 00074 * phi,theta const double[] 00075 * Longitude and latitude in the native coordinate 00076 * system of the projection [deg]. 00077 * 00078 * Returned: 00079 * lng,lat double[] Celestial longitude and latitude [deg]. 00080 * 00081 * Function return value: 00082 * int Status return value: 00083 * 0: Success. 00084 * 00085 * 00086 * sphs2x() - Rotation in the world-to-pixel direction 00087 * --------------------------------------------------- 00088 * sphs2x() transforms celestial coordinates to the native coordinates of a 00089 * projection. 00090 * 00091 * Given: 00092 * eul const double[5] 00093 * Euler angles for the transformation: 00094 * 0: Celestial longitude of the native pole [deg]. 00095 * 1: Celestial colatitude of the native pole, or 00096 * native colatitude of the celestial pole [deg]. 00097 * 2: Native longitude of the celestial pole [deg]. 00098 * 3: cos(eul[1]) 00099 * 4: sin(eul[1]) 00100 * nlng,nlat int Vector lengths. 00101 * sll,spt int Vector strides. 00102 * lng,lat const double[] 00103 * Celestial longitude and latitude [deg]. 00104 * 00105 * Returned: 00106 * phi,theta double[] Longitude and latitude in the native coordinate 00107 * system of the projection [deg]. 00108 * 00109 * Function return value: 00110 * int Status return value: 00111 * 0: Success. 00112 * 00113 * 00114 * sphdpa() - Angular distance and position angle 00115 * ---------------------------------------------- 00116 * sphdpa() computes the angular distance and generalized position angle (see 00117 * notes) from a "reference" point to a number of "field" points on the sphere. 00118 * The points must be specified consistently in any spherical coordinate 00119 * system. 00120 * 00121 * Given: 00122 * nfield int The number of field points. 00123 * lng0,lat0 double Spherical coordinates of the reference point [deg]. 00124 * lng,lat const double[] 00125 * Spherical coordinates of the field points [deg]. 00126 * 00127 * Returned: 00128 * dist,pa double[] Angular distance and position angle [deg]. 00129 * 00130 * Function return value: 00131 * int Status return value: 00132 * 0: Success. 00133 * 00134 * Notes: 00135 * sphdpa() uses sphs2x() to rotate coordinates so that the reference point 00136 * is at the north pole of the new system with the north pole of the old 00137 * system at zero longitude in the new. The Euler angles required by 00138 * sphs2x() for this rotation are 00139 * 00140 = eul[0] = lng0; 00141 = eul[1] = 90.0 - lat0; 00142 = eul[2] = 0.0; 00143 * 00144 * The angular distance and generalized position angle are readily obtained 00145 * from the longitude and latitude of the field point in the new system. 00146 * 00147 * It is evident that the coordinate system in which the two points are 00148 * expressed is irrelevant to the determination of the angular separation 00149 * between the points. However, this is not true of the generalized position 00150 * angle. 00151 * 00152 * The generalized position angle is here defined as the angle of 00153 * intersection of the great circle containing the reference and field points 00154 * with that containing the reference point and the pole. It has its normal 00155 * meaning when the the reference and field points are specified in 00156 * equatorial coordinates (right ascension and declination). 00157 * 00158 * Interchanging the reference and field points changes the position angle in 00159 * a non-intuitive way (because the sum of the angles of a spherical triangle 00160 * normally exceeds 180 degrees). 00161 * 00162 * The position angle is undefined if the reference and field points are 00163 * coincident or antipodal. This may be detected by checking for a distance 00164 * of 0 or 180 degrees (within rounding tolerance). sphdpa() will return an 00165 * arbitrary position angle in such circumstances. 00166 * 00167 *===========================================================================*/ 00168 00169 #ifndef WCSLIB_SPH 00170 #define WCSLIB_SPH 00171 00172 #ifdef __cplusplus 00173 extern "C" { 00174 #endif 00175 00176 00177 int sphx2s(const double eul[5], int nphi, int ntheta, int spt, int sxy, 00178 const double phi[], const double theta[], 00179 double lng[], double lat[]); 00180 00181 int sphs2x(const double eul[5], int nlng, int nlat, int sll , int spt, 00182 const double lng[], const double lat[], 00183 double phi[], double theta[]); 00184 00185 int sphdpa(int nfield, double lng0, double lat0, 00186 const double lng[], const double lat[], 00187 double dist[], double pa[]); 00188 00189 00190 #ifdef __cplusplus 00191 } 00192 #endif 00193 00194 #endif /* WCSLIB_SPH */