File Coverage

erfasrc/src/hd2ae.c
Criterion Covered Total %
statement 0 15 0.0
branch 0 4 0.0
condition n/a
subroutine n/a
pod n/a
total 0 19 0.0


line stmt bran cond sub pod time code
1             #include "erfa.h"
2              
3 0           void eraHd2ae (double ha, double dec, double phi,
4             double *az, double *el)
5             /*
6             ** - - - - - - - - -
7             ** e r a H d 2 a e
8             ** - - - - - - - - -
9             **
10             ** Equatorial to horizon coordinates: transform hour angle and
11             ** declination to azimuth and altitude.
12             **
13             ** Given:
14             ** ha double hour angle (local)
15             ** dec double declination
16             ** phi double site latitude
17             **
18             ** Returned:
19             ** *az double azimuth
20             ** *el double altitude (informally, elevation)
21             **
22             ** Notes:
23             **
24             ** 1) All the arguments are angles in radians.
25             **
26             ** 2) Azimuth is returned in the range 0-2pi; north is zero, and east
27             ** is +pi/2. Altitude is returned in the range +/- pi/2.
28             **
29             ** 3) The latitude phi is pi/2 minus the angle between the Earth's
30             ** rotation axis and the adopted zenith. In many applications it
31             ** will be sufficient to use the published geodetic latitude of the
32             ** site. In very precise (sub-arcsecond) applications, phi can be
33             ** corrected for polar motion.
34             **
35             ** 4) The returned azimuth az is with respect to the rotational north
36             ** pole, as opposed to the ITRS pole, and for sub-arcsecond
37             ** accuracy will need to be adjusted for polar motion if it is to
38             ** be with respect to north on a map of the Earth's surface.
39             **
40             ** 5) Should the user wish to work with respect to the astronomical
41             ** zenith rather than the geodetic zenith, phi will need to be
42             ** adjusted for deflection of the vertical (often tens of
43             ** arcseconds), and the zero point of the hour angle ha will also
44             ** be affected.
45             **
46             ** 6) The transformation is the same as Vh = Rz(pi)*Ry(pi/2-phi)*Ve,
47             ** where Vh and Ve are lefthanded unit vectors in the (az,el) and
48             ** (ha,dec) systems respectively and Ry and Rz are rotations about
49             ** first the y-axis and then the z-axis. (n.b. Rz(pi) simply
50             ** reverses the signs of the x and y components.) For efficiency,
51             ** the algorithm is written out rather than calling other utility
52             ** functions. For applications that require even greater
53             ** efficiency, additional savings are possible if constant terms
54             ** such as functions of latitude are computed once and for all.
55             **
56             ** 7) Again for efficiency, no range checking of arguments is carried
57             ** out.
58             **
59             ** Last revision: 2017 September 12
60             **
61             ** ERFA release 2018-01-30
62             **
63             ** Copyright (C) 2018 IAU ERFA Board. See notes at end.
64             */
65             {
66             double sh, ch, sd, cd, sp, cp, x, y, z, r, a;
67              
68              
69             /* Useful trig functions. */
70 0           sh = sin(ha);
71 0           ch = cos(ha);
72 0           sd = sin(dec);
73 0           cd = cos(dec);
74 0           sp = sin(phi);
75 0           cp = cos(phi);
76              
77             /* Az,Alt unit vector. */
78 0           x = - ch*cd*sp + sd*cp;
79 0           y = - sh*cd;
80 0           z = ch*cd*cp + sd*sp;
81              
82             /* To spherical. */
83 0           r = sqrt(x*x + y*y);
84 0 0         a = (r != 0.0) ? atan2(y,x) : 0.0;
85 0 0         *az = (a < 0.0) ? a+ERFA_D2PI : a;
86 0           *el = 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             */