WCSLIB  4.25.1
wcstrig.h
Go to the documentation of this file.
1 /*============================================================================
2 
3  WCSLIB 4.25 - an implementation of the FITS WCS standard.
4  Copyright (C) 1995-2015, Mark Calabretta
5 
6  This file is part of WCSLIB.
7 
8  WCSLIB is free software: you can redistribute it and/or modify it under the
9  terms of the GNU Lesser General Public License as published by the Free
10  Software Foundation, either version 3 of the License, or (at your option)
11  any later version.
12 
13  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16  more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with WCSLIB. If not, see http://www.gnu.org/licenses.
20 
21  Direct correspondence concerning WCSLIB to mark@calabretta.id.au
22 
23  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
24  http://www.atnf.csiro.au/people/Mark.Calabretta
25  $Id: wcstrig.h,v 4.25.1.3 2015/01/06 01:01:06 mcalabre Exp mcalabre $
26 *=============================================================================
27 *
28 * Summary of the wcstrig routines
29 * -------------------------------
30 * When dealing with celestial coordinate systems and spherical projections
31 * (some moreso than others) it is often desirable to use an angular measure
32 * that provides an exact representation of the latitude of the north or south
33 * pole. The WCSLIB routines use the following trigonometric functions that
34 * take or return angles in degrees:
35 *
36 * - cosd()
37 * - sind()
38 * - tand()
39 * - acosd()
40 * - asind()
41 * - atand()
42 * - atan2d()
43 * - sincosd()
44 *
45 * These "trigd" routines are expected to handle angles that are a multiple of
46 * 90 degrees returning an exact result. Some C implementations provide these
47 * as part of a system library and in such cases it may (or may not!) be
48 * preferable to use them. WCSLIB provides wrappers on the standard trig
49 * functions based on radian measure, adding tests for multiples of 90 degrees.
50 *
51 * However, wcstrig.h also provides the choice of using preprocessor macro
52 * implementations of the trigd functions that don't test for multiples of
53 * 90 degrees (compile with -DWCSTRIG_MACRO). These are typically 20% faster
54 * but may lead to problems near the poles.
55 *
56 *
57 * cosd() - Cosine of an angle in degrees
58 * --------------------------------------
59 * cosd() returns the cosine of an angle given in degrees.
60 *
61 * Given:
62 * angle double [deg].
63 *
64 * Function return value:
65 * double Cosine of the angle.
66 *
67 *
68 * sind() - Sine of an angle in degrees
69 * ------------------------------------
70 * sind() returns the sine of an angle given in degrees.
71 *
72 * Given:
73 * angle double [deg].
74 *
75 * Function return value:
76 * double Sine of the angle.
77 *
78 *
79 * sincosd() - Sine and cosine of an angle in degrees
80 * --------------------------------------------------
81 * sincosd() returns the sine and cosine of an angle given in degrees.
82 *
83 * Given:
84 * angle double [deg].
85 *
86 * Returned:
87 * sin *double Sine of the angle.
88 *
89 * cos *double Cosine of the angle.
90 *
91 * Function return value:
92 * void
93 *
94 *
95 * tand() - Tangent of an angle in degrees
96 * ---------------------------------------
97 * tand() returns the tangent of an angle given in degrees.
98 *
99 * Given:
100 * angle double [deg].
101 *
102 * Function return value:
103 * double Tangent of the angle.
104 *
105 *
106 * acosd() - Inverse cosine, returning angle in degrees
107 * ----------------------------------------------------
108 * acosd() returns the inverse cosine in degrees.
109 *
110 * Given:
111 * x double in the range [-1,1].
112 *
113 * Function return value:
114 * double Inverse cosine of x [deg].
115 *
116 *
117 * asind() - Inverse sine, returning angle in degrees
118 * --------------------------------------------------
119 * asind() returns the inverse sine in degrees.
120 *
121 * Given:
122 * y double in the range [-1,1].
123 *
124 * Function return value:
125 * double Inverse sine of y [deg].
126 *
127 *
128 * atand() - Inverse tangent, returning angle in degrees
129 * -----------------------------------------------------
130 * atand() returns the inverse tangent in degrees.
131 *
132 * Given:
133 * s double
134 *
135 * Function return value:
136 * double Inverse tangent of s [deg].
137 *
138 *
139 * atan2d() - Polar angle of (x,y), in degrees
140 * -------------------------------------------
141 * atan2d() returns the polar angle, beta, in degrees, of polar coordinates
142 * (rho,beta) corresponding to Cartesian coordinates (x,y). It is equivalent
143 * to the arg(x,y) function of WCS Paper II, though with transposed arguments.
144 *
145 * Given:
146 * y double Cartesian y-coordinate.
147 *
148 * x double Cartesian x-coordinate.
149 *
150 * Function return value:
151 * double Polar angle of (x,y) [deg].
152 *
153 *===========================================================================*/
154 
155 #ifndef WCSLIB_WCSTRIG
156 #define WCSLIB_WCSTRIG
157 
158 #include <math.h>
159 
160 #include "wcsconfig.h"
161 
162 #ifdef HAVE_SINCOS
163  void sincos(double angle, double *sin, double *cos);
164 #endif
165 
166 #ifdef __cplusplus
167 extern "C" {
168 #endif
169 
170 
171 #ifdef WCSTRIG_MACRO
172 
173 /* Macro implementation of the trigd functions. */
174 #include "wcsmath.h"
175 
176 #define cosd(X) cos((X)*D2R)
177 #define sind(X) sin((X)*D2R)
178 #define tand(X) tan((X)*D2R)
179 #define acosd(X) acos(X)*R2D
180 #define asind(X) asin(X)*R2D
181 #define atand(X) atan(X)*R2D
182 #define atan2d(Y,X) atan2(Y,X)*R2D
183 #ifdef HAVE_SINCOS
184  #define sincosd(X,S,C) sincos((X)*D2R,(S),(C))
185 #else
186  #define sincosd(X,S,C) *(S) = sin((X)*D2R); *(C) = cos((X)*D2R);
187 #endif
188 
189 #else
190 
191 /* Use WCSLIB wrappers or native trigd functions. */
192 
193 double cosd(double angle);
194 double sind(double angle);
195 void sincosd(double angle, double *sin, double *cos);
196 double tand(double angle);
197 double acosd(double x);
198 double asind(double y);
199 double atand(double s);
200 double atan2d(double y, double x);
201 
202 /* Domain tolerance for asin() and acos() functions. */
203 #define WCSTRIG_TOL 1e-10
204 
205 #endif /* WCSTRIG_MACRO */
206 
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif /* WCSLIB_WCSTRIG */
void sincosd(double angle, double *sin, double *cos)
Sine and cosine of an angle in degrees.
double cosd(double angle)
Cosine of an angle in degrees.
double asind(double y)
Inverse sine, returning angle in degrees.
double acosd(double x)
Inverse cosine, returning angle in degrees.
double tand(double angle)
Tangent of an angle in degrees.
double atan2d(double y, double x)
Polar angle of , in degrees.
double atand(double s)
Inverse tangent, returning angle in degrees.
double sind(double angle)
Sine of an angle in degrees.