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: wcstrig_8h-source.html,v 1.1 2009/09/14 20:25:25 irby Exp $ 00032 *============================================================================= 00033 * 00034 * Summary of the wcstrig routines 00035 * ------------------------------- 00036 * When dealing with celestial coordinate systems and spherical projections 00037 * (some moreso than others) it is often desirable to use an angular measure 00038 * that provides an exact representation of the latitude of the north or south 00039 * pole. The WCSLIB routines use the following trigonometric functions that 00040 * take or return angles in degrees: 00041 * 00042 * - cosd() 00043 * - sind() 00044 * - tand() 00045 * - acosd() 00046 * - asind() 00047 * - atand() 00048 * - atan2d() 00049 * - sincosd() 00050 * 00051 * These "trigd" routines are expected to handle angles that are a multiple of 00052 * 90 degrees returning an exact result. Some C implementations provide these 00053 * as part of a system library and in such cases it may (or may not!) be 00054 * preferable to use them. WCSLIB provides wrappers on the standard trig 00055 * functions based on radian measure, adding tests for multiples of 90 degrees. 00056 * 00057 * However, wcstrig.h also provides the choice of using preprocessor macro 00058 * implementations of the trigd functions that don't test for multiples of 00059 * 90 degrees (compile with -DWCSTRIG_MACRO). These are typically 20% faster 00060 * but may lead to problems near the poles. 00061 * 00062 * 00063 * cosd() - Cosine of an angle in degrees 00064 * -------------------------------------- 00065 * cosd() returns the cosine of an angle given in degrees. 00066 * 00067 * Given: 00068 * angle double [deg]. 00069 * 00070 * Function return value: 00071 * double Cosine of the angle. 00072 * 00073 * 00074 * sind() - Sine of an angle in degrees 00075 * ------------------------------------ 00076 * sind() returns the sine of an angle given in degrees. 00077 * 00078 * Given: 00079 * angle double [deg]. 00080 * 00081 * Function return value: 00082 * double Sine of the angle. 00083 * 00084 * 00085 * sincosd() - Sine and cosine of an angle in degrees 00086 * -------------------------------------------------- 00087 * sincosd() returns the sine and cosine of an angle given in degrees. 00088 * 00089 * Given: 00090 * angle double [deg]. 00091 * 00092 * Returned: 00093 * sin *double Sine of the angle. 00094 * cos *double Cosine of the angle. 00095 * 00096 * Function return value: 00097 * void 00098 * 00099 * 00100 * tand() - Tangent of an angle in degrees 00101 * --------------------------------------- 00102 * tand() returns the tangent of an angle given in degrees. 00103 * 00104 * Given: 00105 * angle double [deg]. 00106 * 00107 * Function return value: 00108 * double Tangent of the angle. 00109 * 00110 * 00111 * acosd() - Inverse cosine, returning angle in degrees 00112 * ---------------------------------------------------- 00113 * acosd() returns the inverse cosine in degrees. 00114 * 00115 * Given: 00116 * x double in the range [-1,1]. 00117 * 00118 * Function return value: 00119 * double Inverse cosine of x [deg]. 00120 * 00121 * 00122 * asind() - Inverse sine, returning angle in degrees 00123 * -------------------------------------------------- 00124 * asind() returns the inverse sine in degrees. 00125 * 00126 * Given: 00127 * y double in the range [-1,1]. 00128 * 00129 * Function return value: 00130 * double Inverse sine of y [deg]. 00131 * 00132 * 00133 * atand() - Inverse tangent, returning angle in degrees 00134 * ----------------------------------------------------- 00135 * atand() returns the inverse tangent in degrees. 00136 * 00137 * Given: 00138 * s double 00139 * 00140 * Function return value: 00141 * double Inverse tangent of s [deg]. 00142 * 00143 * 00144 * atan2d() - Polar angle of (x,y), in degrees 00145 * ------------------------------------------- 00146 * atan2d() returns the polar angle, beta, in degrees, of polar coordinates 00147 * (rho,beta) corresponding Cartesian coordinates (x,y). It is equivalent to 00148 * the arg(x,y) function of WCS Paper II, though with transposed arguments. 00149 * 00150 * Given: 00151 * y double Cartesian y-coordinate. 00152 * x double Cartesian x-coordinate. 00153 * 00154 * Function return value: 00155 * double Polar angle of (x,y) [deg]. 00156 * 00157 *===========================================================================*/ 00158 00159 #ifndef WCSLIB_WCSTRIG 00160 #define WCSLIB_WCSTRIG 00161 00162 #include <math.h> 00163 00164 #include "wcsconfig.h" 00165 00166 #ifdef HAVE_SINCOS 00167 void sincos(double angle, double *sin, double *cos); 00168 #endif 00169 00170 #ifdef __cplusplus 00171 extern "C" { 00172 #endif 00173 00174 00175 #ifdef WCSTRIG_MACRO 00176 00177 /* Macro implementation of the trigd functions. */ 00178 #include "wcsmath.h" 00179 00180 #define cosd(X) cos((X)*D2R) 00181 #define sind(X) sin((X)*D2R) 00182 #define tand(X) tan((X)*D2R) 00183 #define acosd(X) acos(X)*R2D 00184 #define asind(X) asin(X)*R2D 00185 #define atand(X) atan(X)*R2D 00186 #define atan2d(Y,X) atan2(Y,X)*R2D 00187 #ifdef HAVE_SINCOS 00188 #define sincosd(X,S,C) sincos((X)*D2R,(S),(C)) 00189 #else 00190 #define sincosd(X,S,C) *(S) = sin((X)*D2R); *(C) = cos((X)*D2R); 00191 #endif 00192 00193 #else 00194 00195 /* Use WCSLIB wrappers or native trigd functions. */ 00196 00197 double cosd(double angle); 00198 double sind(double angle); 00199 void sincosd(double angle, double *sin, double *cos); 00200 double tand(double angle); 00201 double acosd(double x); 00202 double asind(double y); 00203 double atand(double s); 00204 double atan2d(double y, double x); 00205 00206 /* Domain tolerance for asin() and acos() functions. */ 00207 #define WCSTRIG_TOL 1e-10 00208 00209 #endif /* WCSTRIG_MACRO */ 00210 00211 00212 #ifdef __cplusplus 00213 } 00214 #endif 00215 00216 #endif /* WCSLIB_WCSTRIG */