WCSLIB: wcstrig.h Source File

WCSLIB 5.17

wcstrig.h
Go to the documentation of this file.
1 /*============================================================================
2
3 WCSLIB 5.17 - an implementation of the FITS WCS standard.
4 Copyright (C) 1995-2017, 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 5.17 2017/09/18 08:44:23 mcalabre Exp $
26 *=============================================================================
27 *
28 * WCSLIB 5.17 - C routines that implement the FITS World Coordinate System
29 * (WCS) standard. Refer to the README file provided with WCSLIB for an
30 * overview of the library.
31 *
32 *
33 * Summary of the wcstrig routines
34 * -------------------------------
35 * When dealing with celestial coordinate systems and spherical projections
36 * (some moreso than others) it is often desirable to use an angular measure
37 * that provides an exact representation of the latitude of the north or south
38 * pole. The WCSLIB routines use the following trigonometric functions that
39 * take or return angles in degrees:
40 *
41 * - cosd()
42 * - sind()
43 * - tand()
44 * - acosd()
45 * - asind()
46 * - atand()
47 * - atan2d()
48 * - sincosd()
49 *
50 * These "trigd" routines are expected to handle angles that are a multiple of
51 * 90 degrees returning an exact result. Some C implementations provide these
52 * as part of a system library and in such cases it may (or may not!) be
53 * preferable to use them. WCSLIB provides wrappers on the standard trig
54 * functions based on radian measure, adding tests for multiples of 90 degrees.
55 *
56 * However, wcstrig.h also provides the choice of using preprocessor macro
57 * implementations of the trigd functions that don't test for multiples of
58 * 90 degrees (compile with -DWCSTRIG_MACRO). These are typically 20% faster
59 * but may lead to problems near the poles.
60 *
61 *
62 * cosd() - Cosine of an angle in degrees
63 * --------------------------------------
64 * cosd() returns the cosine of an angle given in degrees.
65 *
66 * Given:
67 * angle double [deg].
68 *
69 * Function return value:
70 * double Cosine of the angle.
71 *
72 *
73 * sind() - Sine of an angle in degrees
74 * ------------------------------------
75 * sind() returns the sine of an angle given in degrees.
76 *
77 * Given:
78 * angle double [deg].
79 *
80 * Function return value:
81 * double Sine of the angle.
82 *
83 *
84 * sincosd() - Sine and cosine of an angle in degrees
85 * --------------------------------------------------
86 * sincosd() returns the sine and cosine of an angle given in degrees.
87 *
88 * Given:
89 * angle double [deg].
90 *
91 * Returned:
92 * sin *double Sine of the angle.
93 *
94 * cos *double Cosine of the angle.
95 *
96 * Function return value:
97 * void
98 *
99 *
100 * tand() - Tangent of an angle in degrees
101 * ---------------------------------------
102 * tand() returns the tangent of an angle given in degrees.
103 *
104 * Given:
105 * angle double [deg].
106 *
107 * Function return value:
108 * double Tangent of the angle.
109 *
110 *
111 * acosd() - Inverse cosine, returning angle in degrees
112 * ----------------------------------------------------
113 * acosd() returns the inverse cosine in degrees.
114 *
115 * Given:
116 * x double in the range [-1,1].
117 *
118 * Function return value:
119 * double Inverse cosine of x [deg].
120 *
121 *
122 * asind() - Inverse sine, returning angle in degrees
123 * --------------------------------------------------
124 * asind() returns the inverse sine in degrees.
125 *
126 * Given:
127 * y double in the range [-1,1].
128 *
129 * Function return value:
130 * double Inverse sine of y [deg].
131 *
132 *
133 * atand() - Inverse tangent, returning angle in degrees
134 * -----------------------------------------------------
135 * atand() returns the inverse tangent in degrees.
136 *
137 * Given:
138 * s double
139 *
140 * Function return value:
141 * double Inverse tangent of s [deg].
142 *
143 *
144 * atan2d() - Polar angle of (x,y), in degrees
145 * -------------------------------------------
146 * atan2d() returns the polar angle, beta, in degrees, of polar coordinates
147 * (rho,beta) corresponding to Cartesian coordinates (x,y). It is equivalent
148 * to the arg(x,y) function of WCS Paper II, though with transposed arguments.
149 *
150 * Given:
151 * y double Cartesian y-coordinate.
152 *
153 * x double Cartesian x-coordinate.
154 *
155 * Function return value:
156 * double Polar angle of (x,y) [deg].
157 *
158 *===========================================================================*/
159
160 #ifndef WCSLIB_WCSTRIG
161 #define WCSLIB_WCSTRIG
162
163 #include <math.h>
164
165 #include "wcsconfig.h"
166
167 #ifdef HAVE_SINCOS
168 void sincos(double angle, double *sin, double *cos);
169 #endif
170
171 #ifdef __cplusplus
172 extern "C" {
173 #endif
174
175
176 #ifdef WCSTRIG_MACRO
177
178 /* Macro implementation of the trigd functions. */
179 #include "wcsmath.h"
180
181 #define cosd(X) cos((X)*D2R)
182 #define sind(X) sin((X)*D2R)
183 #define tand(X) tan((X)*D2R)
184 #define acosd(X) acos(X)*R2D
185 #define asind(X) asin(X)*R2D
186 #define atand(X) atan(X)*R2D
187 #define atan2d(Y,X) atan2(Y,X)*R2D
188 #ifdef HAVE_SINCOS
189 #define sincosd(X,S,C) sincos((X)*D2R,(S),(C))
190 #else
191 #define sincosd(X,S,C) *(S) = sin((X)*D2R); *(C) = cos((X)*D2R);
192 #endif
193
194 #else
195
196 /* Use WCSLIB wrappers or native trigd functions. */
197
198 double cosd(double angle);
199 double sind(double angle);
200 void sincosd(double angle, double *sin, double *cos);
201 double tand(double angle);
202 double acosd(double x);
203 double asind(double y);
204 double atand(double s);
205 double atan2d(double y, double x);
206
207 /* Domain tolerance for asin() and acos() functions. */
208 #define WCSTRIG_TOL 1e-10
209
210 #endif /* WCSTRIG_MACRO */
211
212
213 #ifdef __cplusplus
214 }
215 #endif
216
217 #endif /* WCSLIB_WCSTRIG */
sincosd
void sincosd(double angle, double *sin, double *cos)
Sine and cosine of an angle in degrees.
cosd
double cosd(double angle)
Cosine of an angle in degrees.
asind
double asind(double y)
Inverse sine, returning angle in degrees.
acosd
double acosd(double x)
Inverse cosine, returning angle in degrees.
tand
double tand(double angle)
Tangent of an angle in degrees.
wcsmath.h
atan2d
double atan2d(double y, double x)
Polar angle of , in degrees.
atand
double atand(double s)
Inverse tangent, returning angle in degrees.
sind
double sind(double angle)
Sine of an angle in degrees.