File Coverage

erfasrc/src/ae2hd.c
Criterion Covered Total %
statement 0 14 0.0
branch 0 2 0.0
condition n/a
subroutine n/a
pod n/a
total 0 16 0.0


line stmt bran cond sub pod time code
1             #include "erfa.h"
2              
3 0           void eraAe2hd (double az, double el, double phi,
4             double *ha, double *dec)
5             /*
6             ** - - - - - - - - -
7             ** e r a A e 2 h d
8             ** - - - - - - - - -
9             **
10             ** Horizon to equatorial coordinates: transform azimuth and altitude
11             ** to hour angle and declination.
12             **
13             ** Given:
14             ** az double azimuth
15             ** el double altitude (informally, elevation)
16             ** phi double site latitude
17             **
18             ** Returned:
19             ** ha double hour angle (local)
20             ** dec double declination
21             **
22             ** Notes:
23             **
24             ** 1) All the arguments are angles in radians.
25             **
26             ** 2) The sign convention for azimuth is north zero, east +pi/2.
27             **
28             ** 3) HA is returned in the range +/-pi. Declination is returned in
29             ** the range +/-pi/2.
30             **
31             ** 4) The latitude phi is pi/2 minus the angle between the Earth's
32             ** rotation axis and the adopted zenith. In many applications it
33             ** will be sufficient to use the published geodetic latitude of the
34             ** site. In very precise (sub-arcsecond) applications, phi can be
35             ** corrected for polar motion.
36             **
37             ** 5) The azimuth az must be with respect to the rotational north pole,
38             ** as opposed to the ITRS pole, and an azimuth with respect to north
39             ** on a map of the Earth's surface will need to be adjusted for
40             ** polar motion if sub-arcsecond accuracy is required.
41             **
42             ** 6) Should the user wish to work with respect to the astronomical
43             ** zenith rather than the geodetic zenith, phi will need to be
44             ** adjusted for deflection of the vertical (often tens of
45             ** arcseconds), and the zero point of ha will also be affected.
46             **
47             ** 7) The transformation is the same as Ve = Ry(phi-pi/2)*Rz(pi)*Vh,
48             ** where Ve and Vh are lefthanded unit vectors in the (ha,dec) and
49             ** (az,el) systems respectively and Rz and Ry are rotations about
50             ** first the z-axis and then the y-axis. (n.b. Rz(pi) simply
51             ** reverses the signs of the x and y components.) For efficiency,
52             ** the algorithm is written out rather than calling other utility
53             ** functions. For applications that require even greater
54             ** efficiency, additional savings are possible if constant terms
55             ** such as functions of latitude are computed once and for all.
56             **
57             ** 8) Again for efficiency, no range checking of arguments is carried
58             ** out.
59             **
60             ** Last revision: 2017 September 12
61             **
62             ** ERFA release 2018-01-30
63             **
64             ** Copyright (C) 2018 IAU ERFA Board. See notes at end.
65             */
66             {
67             double sa, ca, se, ce, sp, cp, x, y, z, r;
68              
69              
70             /* Useful trig functions. */
71 0           sa = sin(az);
72 0           ca = cos(az);
73 0           se = sin(el);
74 0           ce = cos(el);
75 0           sp = sin(phi);
76 0           cp = cos(phi);
77              
78             /* HA,Dec unit vector. */
79 0           x = - ca*ce*sp + se*cp;
80 0           y = - sa*ce;
81 0           z = ca*ce*cp + se*sp;
82              
83             /* To spherical. */
84 0           r = sqrt(x*x + y*y);
85 0 0         *ha = (r != 0.0) ? atan2(y,x) : 0.0;
86 0           *dec = atan2(z,r);
87              
88             /* Finished. */
89              
90 0           }
91             /*----------------------------------------------------------------------
92             **
93             **
94             ** Copyright (C) 2013-2019, NumFOCUS Foundation.
95             ** All rights reserved.
96             **
97             ** This library is derived, with permission, from the International
98             ** Astronomical Union's "Standards of Fundamental Astronomy" library,
99             ** available from http://www.iausofa.org.
100             **
101             ** The ERFA version is intended to retain identical functionality to
102             ** the SOFA library, but made distinct through different function and
103             ** file names, as set out in the SOFA license conditions. The SOFA
104             ** original has a role as a reference standard for the IAU and IERS,
105             ** and consequently redistribution is permitted only in its unaltered
106             ** state. The ERFA version is not subject to this restriction and
107             ** therefore can be included in distributions which do not support the
108             ** concept of "read only" software.
109             **
110             ** Although the intent is to replicate the SOFA API (other than
111             ** replacement of prefix names) and results (with the exception of
112             ** bugs; any that are discovered will be fixed), SOFA is not
113             ** responsible for any errors found in this version of the library.
114             **
115             ** If you wish to acknowledge the SOFA heritage, please acknowledge
116             ** that you are using a library derived from SOFA, rather than SOFA
117             ** itself.
118             **
119             **
120             ** TERMS AND CONDITIONS
121             **
122             ** Redistribution and use in source and binary forms, with or without
123             ** modification, are permitted provided that the following conditions
124             ** are met:
125             **
126             ** 1 Redistributions of source code must retain the above copyright
127             ** notice, this list of conditions and the following disclaimer.
128             **
129             ** 2 Redistributions in binary form must reproduce the above copyright
130             ** notice, this list of conditions and the following disclaimer in
131             ** the documentation and/or other materials provided with the
132             ** distribution.
133             **
134             ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
135             ** the International Astronomical Union nor the names of its
136             ** contributors may be used to endorse or promote products derived
137             ** from this software without specific prior written permission.
138             **
139             ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
140             ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
141             ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
142             ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
143             ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
144             ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
145             ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
146             ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
147             ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
148             ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
149             ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
150             ** POSSIBILITY OF SUCH DAMAGE.
151             **
152             */