File Coverage

erfasrc/src/tpxes.c
Criterion Covered Total %
statement 0 15 0.0
branch 0 6 0.0
condition n/a
subroutine n/a
pod n/a
total 0 21 0.0


line stmt bran cond sub pod time code
1             #include "erfa.h"
2              
3 0           int eraTpxes(double a, double b, double a0, double b0,
4             double *xi, double *eta)
5             /*
6             ** - - - - - - - - -
7             ** e r a T p x e s
8             ** - - - - - - - - -
9             **
10             ** In the tangent plane projection, given celestial spherical
11             ** coordinates for a star and the tangent point, solve for the star's
12             ** rectangular coordinates in the tangent plane.
13             **
14             ** Given:
15             ** a,b double star's spherical coordinates
16             ** a0,b0 double tangent point's spherical coordinates
17             **
18             ** Returned:
19             ** *xi,*eta double rectangular coordinates of star image (Note 2)
20             **
21             ** Returned (function value):
22             ** int status: 0 = OK
23             ** 1 = star too far from axis
24             ** 2 = antistar on tangent plane
25             ** 3 = antistar too far from axis
26             **
27             ** Notes:
28             **
29             ** 1) The tangent plane projection is also called the "gnomonic
30             ** projection" and the "central projection".
31             **
32             ** 2) The eta axis points due north in the adopted coordinate system.
33             ** If the spherical coordinates are observed (RA,Dec), the tangent
34             ** plane coordinates (xi,eta) are conventionally called the
35             ** "standard coordinates". For right-handed spherical coordinates,
36             ** (xi,eta) are also right-handed. The units of (xi,eta) are,
37             ** effectively, radians at the tangent point.
38             **
39             ** 3) All angular arguments are in radians.
40             **
41             ** 4) This function is a member of the following set:
42             **
43             ** spherical vector solve for
44             **
45             ** > eraTpxes < eraTpxev xi,eta
46             ** eraTpsts eraTpstv star
47             ** eraTpors eraTporv origin
48             **
49             ** References:
50             **
51             ** Calabretta M.R. & Greisen, E.W., 2002, "Representations of
52             ** celestial coordinates in FITS", Astron.Astrophys. 395, 1077
53             **
54             ** Green, R.M., "Spherical Astronomy", Cambridge University Press,
55             ** 1987, Chapter 13.
56             **
57             ** Copyright (C) 2013-2020, NumFOCUS Foundation.
58             ** Derived, with permission, from the SOFA library. See notes at end of file.
59             */
60             {
61             const double TINY = 1e-6;
62             int j;
63             double sb0, sb, cb0, cb, da, sda, cda, d;
64              
65              
66             /* Functions of the spherical coordinates. */
67 0           sb0 = sin(b0);
68 0           sb = sin(b);
69 0           cb0 = cos(b0);
70 0           cb = cos(b);
71 0           da = a - a0;
72 0           sda = sin(da);
73 0           cda = cos(da);
74              
75             /* Reciprocal of star vector length to tangent plane. */
76 0           d = sb*sb0 + cb*cb0*cda;
77              
78             /* Check for error cases. */
79 0 0         if ( d > TINY ) {
80             j = 0;
81 0 0         } else if ( d >= 0.0 ) {
82             j = 1;
83             d = TINY;
84 0 0         } else if ( d > -TINY ) {
85             j = 2;
86             d = -TINY;
87             } else {
88             j = 3;
89             }
90              
91             /* Return the tangent plane coordinates (even in dubious cases). */
92 0           *xi = cb*sda / d;
93 0           *eta = (sb*cb0 - cb*sb0*cda) / d;
94              
95             /* Return the status. */
96 0           return j;
97              
98             /* Finished. */
99              
100             }
101             /*----------------------------------------------------------------------
102             **
103             **
104             ** Copyright (C) 2013-2020, NumFOCUS Foundation.
105             ** All rights reserved.
106             **
107             ** This library is derived, with permission, from the International
108             ** Astronomical Union's "Standards of Fundamental Astronomy" library,
109             ** available from http://www.iausofa.org.
110             **
111             ** The ERFA version is intended to retain identical functionality to
112             ** the SOFA library, but made distinct through different function and
113             ** file names, as set out in the SOFA license conditions. The SOFA
114             ** original has a role as a reference standard for the IAU and IERS,
115             ** and consequently redistribution is permitted only in its unaltered
116             ** state. The ERFA version is not subject to this restriction and
117             ** therefore can be included in distributions which do not support the
118             ** concept of "read only" software.
119             **
120             ** Although the intent is to replicate the SOFA API (other than
121             ** replacement of prefix names) and results (with the exception of
122             ** bugs; any that are discovered will be fixed), SOFA is not
123             ** responsible for any errors found in this version of the library.
124             **
125             ** If you wish to acknowledge the SOFA heritage, please acknowledge
126             ** that you are using a library derived from SOFA, rather than SOFA
127             ** itself.
128             **
129             **
130             ** TERMS AND CONDITIONS
131             **
132             ** Redistribution and use in source and binary forms, with or without
133             ** modification, are permitted provided that the following conditions
134             ** are met:
135             **
136             ** 1 Redistributions of source code must retain the above copyright
137             ** notice, this list of conditions and the following disclaimer.
138             **
139             ** 2 Redistributions in binary form must reproduce the above copyright
140             ** notice, this list of conditions and the following disclaimer in
141             ** the documentation and/or other materials provided with the
142             ** distribution.
143             **
144             ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
145             ** the International Astronomical Union nor the names of its
146             ** contributors may be used to endorse or promote products derived
147             ** from this software without specific prior written permission.
148             **
149             ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
150             ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
151             ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
152             ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
153             ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
154             ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
155             ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
156             ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
157             ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
158             ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
159             ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
160             ** POSSIBILITY OF SUCH DAMAGE.
161             **
162             */