00001 /*============================================================================ 00002 00003 WCSLIB 4.13 - an implementation of the FITS WCS standard. 00004 Copyright (C) 1995-2012, 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.h,v 4.13.1.1 2012/03/14 07:40:37 cal103 Exp cal103 $ 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 * 00095 * cos *double Cosine of the angle. 00096 * 00097 * Function return value: 00098 * void 00099 * 00100 * 00101 * tand() - Tangent of an angle in degrees 00102 * --------------------------------------- 00103 * tand() returns the tangent of an angle given in degrees. 00104 * 00105 * Given: 00106 * angle double [deg]. 00107 * 00108 * Function return value: 00109 * double Tangent of the angle. 00110 * 00111 * 00112 * acosd() - Inverse cosine, returning angle in degrees 00113 * ---------------------------------------------------- 00114 * acosd() returns the inverse cosine in degrees. 00115 * 00116 * Given: 00117 * x double in the range [-1,1]. 00118 * 00119 * Function return value: 00120 * double Inverse cosine of x [deg]. 00121 * 00122 * 00123 * asind() - Inverse sine, returning angle in degrees 00124 * -------------------------------------------------- 00125 * asind() returns the inverse sine in degrees. 00126 * 00127 * Given: 00128 * y double in the range [-1,1]. 00129 * 00130 * Function return value: 00131 * double Inverse sine of y [deg]. 00132 * 00133 * 00134 * atand() - Inverse tangent, returning angle in degrees 00135 * ----------------------------------------------------- 00136 * atand() returns the inverse tangent in degrees. 00137 * 00138 * Given: 00139 * s double 00140 * 00141 * Function return value: 00142 * double Inverse tangent of s [deg]. 00143 * 00144 * 00145 * atan2d() - Polar angle of (x,y), in degrees 00146 * ------------------------------------------- 00147 * atan2d() returns the polar angle, beta, in degrees, of polar coordinates 00148 * (rho,beta) corresponding Cartesian coordinates (x,y). It is equivalent to 00149 * the arg(x,y) function of WCS Paper II, though with transposed arguments. 00150 * 00151 * Given: 00152 * y double Cartesian y-coordinate. 00153 * 00154 * x double Cartesian x-coordinate. 00155 * 00156 * Function return value: 00157 * double Polar angle of (x,y) [deg]. 00158 * 00159 *===========================================================================*/ 00160 00161 #ifndef WCSLIB_WCSTRIG 00162 #define WCSLIB_WCSTRIG 00163 00164 #include <math.h> 00165 00166 #include "wcsconfig.h" 00167 00168 #ifdef HAVE_SINCOS 00169 void sincos(double angle, double *sin, double *cos); 00170 #endif 00171 00172 #ifdef __cplusplus 00173 extern "C" { 00174 #endif 00175 00176 00177 #ifdef WCSTRIG_MACRO 00178 00179 /* Macro implementation of the trigd functions. */ 00180 #include "wcsmath.h" 00181 00182 #define cosd(X) cos((X)*D2R) 00183 #define sind(X) sin((X)*D2R) 00184 #define tand(X) tan((X)*D2R) 00185 #define acosd(X) acos(X)*R2D 00186 #define asind(X) asin(X)*R2D 00187 #define atand(X) atan(X)*R2D 00188 #define atan2d(Y,X) atan2(Y,X)*R2D 00189 #ifdef HAVE_SINCOS 00190 #define sincosd(X,S,C) sincos((X)*D2R,(S),(C)) 00191 #else 00192 #define sincosd(X,S,C) *(S) = sin((X)*D2R); *(C) = cos((X)*D2R); 00193 #endif 00194 00195 #else 00196 00197 /* Use WCSLIB wrappers or native trigd functions. */ 00198 00199 double cosd(double angle); 00200 double sind(double angle); 00201 void sincosd(double angle, double *sin, double *cos); 00202 double tand(double angle); 00203 double acosd(double x); 00204 double asind(double y); 00205 double atand(double s); 00206 double atan2d(double y, double x); 00207 00208 /* Domain tolerance for asin() and acos() functions. */ 00209 #define WCSTRIG_TOL 1e-10 00210 00211 #endif /* WCSTRIG_MACRO */ 00212 00213 00214 #ifdef __cplusplus 00215 } 00216 #endif 00217 00218 #endif /* WCSLIB_WCSTRIG */