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