File Coverage

erfasrc/src/eors.c
Criterion Covered Total %
statement 10 10 100.0
branch 1 2 50.0
condition n/a
subroutine n/a
pod n/a
total 11 12 91.6


line stmt bran cond sub pod time code
1             #include "erfa.h"
2              
3 3           double eraEors(double rnpb[3][3], double s)
4             /*
5             ** - - - - - - - -
6             ** e r a E o r s
7             ** - - - - - - - -
8             **
9             ** Equation of the origins, given the classical NPB matrix and the
10             ** quantity s.
11             **
12             ** Given:
13             ** rnpb double[3][3] classical nutation x precession x bias matrix
14             ** s double the quantity s (the CIO locator)
15             **
16             ** Returned (function value):
17             ** double the equation of the origins in radians.
18             **
19             ** Notes:
20             **
21             ** 1) The equation of the origins is the distance between the true
22             ** equinox and the celestial intermediate origin and, equivalently,
23             ** the difference between Earth rotation angle and Greenwich
24             ** apparent sidereal time (ERA-GST). It comprises the precession
25             ** (since J2000.0) in right ascension plus the equation of the
26             ** equinoxes (including the small correction terms).
27             **
28             ** 2) The algorithm is from Wallace & Capitaine (2006).
29             **
30             ** References:
31             **
32             ** Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
33             **
34             ** Wallace, P. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
35             **
36             ** Copyright (C) 2013-2019, NumFOCUS Foundation.
37             ** Derived, with permission, from the SOFA library. See notes at end of file.
38             */
39             {
40             double x, ax, xs, ys, zs, p, q, eo;
41              
42              
43             /* Evaluate Wallace & Capitaine (2006) expression (16). */
44 3           x = rnpb[2][0];
45 3           ax = x / (1.0 + rnpb[2][2]);
46 3           xs = 1.0 - ax * x;
47 3           ys = -ax * rnpb[2][1];
48 3           zs = -x;
49 3           p = rnpb[0][0] * xs + rnpb[0][1] * ys + rnpb[0][2] * zs;
50 3           q = rnpb[1][0] * xs + rnpb[1][1] * ys + rnpb[1][2] * zs;
51 3 50         eo = ((p != 0) || (q != 0)) ? s - atan2(q, p) : s;
52              
53 3           return eo;
54              
55             }
56             /*----------------------------------------------------------------------
57             **
58             **
59             ** Copyright (C) 2013-2019, NumFOCUS Foundation.
60             ** All rights reserved.
61             **
62             ** This library is derived, with permission, from the International
63             ** Astronomical Union's "Standards of Fundamental Astronomy" library,
64             ** available from http://www.iausofa.org.
65             **
66             ** The ERFA version is intended to retain identical functionality to
67             ** the SOFA library, but made distinct through different function and
68             ** file names, as set out in the SOFA license conditions. The SOFA
69             ** original has a role as a reference standard for the IAU and IERS,
70             ** and consequently redistribution is permitted only in its unaltered
71             ** state. The ERFA version is not subject to this restriction and
72             ** therefore can be included in distributions which do not support the
73             ** concept of "read only" software.
74             **
75             ** Although the intent is to replicate the SOFA API (other than
76             ** replacement of prefix names) and results (with the exception of
77             ** bugs; any that are discovered will be fixed), SOFA is not
78             ** responsible for any errors found in this version of the library.
79             **
80             ** If you wish to acknowledge the SOFA heritage, please acknowledge
81             ** that you are using a library derived from SOFA, rather than SOFA
82             ** itself.
83             **
84             **
85             ** TERMS AND CONDITIONS
86             **
87             ** Redistribution and use in source and binary forms, with or without
88             ** modification, are permitted provided that the following conditions
89             ** are met:
90             **
91             ** 1 Redistributions of source code must retain the above copyright
92             ** notice, this list of conditions and the following disclaimer.
93             **
94             ** 2 Redistributions in binary form must reproduce the above copyright
95             ** notice, this list of conditions and the following disclaimer in
96             ** the documentation and/or other materials provided with the
97             ** distribution.
98             **
99             ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
100             ** the International Astronomical Union nor the names of its
101             ** contributors may be used to endorse or promote products derived
102             ** from this software without specific prior written permission.
103             **
104             ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
105             ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
106             ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
107             ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
108             ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
109             ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
110             ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
111             ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
112             ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
113             ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
114             ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
115             ** POSSIBILITY OF SUCH DAMAGE.
116             **
117             */