WCSLIB: wcstrig.h Source File

WCSLIB 7.3.1

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