line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "erfa.h" |
2
|
|
|
|
|
|
|
|
3
|
0
|
|
|
|
|
|
int eraTpors(double xi, double eta, double a, double b, |
4
|
|
|
|
|
|
|
double *a01, double *b01, double *a02, double *b02) |
5
|
|
|
|
|
|
|
/* |
6
|
|
|
|
|
|
|
** - - - - - - - - - |
7
|
|
|
|
|
|
|
** e r a T p o r s |
8
|
|
|
|
|
|
|
** - - - - - - - - - |
9
|
|
|
|
|
|
|
** |
10
|
|
|
|
|
|
|
** In the tangent plane projection, given the rectangular coordinates |
11
|
|
|
|
|
|
|
** of a star and its spherical coordinates, determine the spherical |
12
|
|
|
|
|
|
|
** coordinates of the tangent point. |
13
|
|
|
|
|
|
|
** |
14
|
|
|
|
|
|
|
** Given: |
15
|
|
|
|
|
|
|
** xi,eta double rectangular coordinates of star image (Note 2) |
16
|
|
|
|
|
|
|
** a,b double star's spherical coordinates (Note 3) |
17
|
|
|
|
|
|
|
** |
18
|
|
|
|
|
|
|
** Returned: |
19
|
|
|
|
|
|
|
** *a01,*b01 double tangent point's spherical coordinates, Soln. 1 |
20
|
|
|
|
|
|
|
** *a02,*b02 double tangent point's spherical coordinates, Soln. 2 |
21
|
|
|
|
|
|
|
** |
22
|
|
|
|
|
|
|
** Returned (function value): |
23
|
|
|
|
|
|
|
** int number of solutions: |
24
|
|
|
|
|
|
|
** 0 = no solutions returned (Note 5) |
25
|
|
|
|
|
|
|
** 1 = only the first solution is useful (Note 6) |
26
|
|
|
|
|
|
|
** 2 = both solutions are useful (Note 6) |
27
|
|
|
|
|
|
|
** |
28
|
|
|
|
|
|
|
** Notes: |
29
|
|
|
|
|
|
|
** |
30
|
|
|
|
|
|
|
** 1) The tangent plane projection is also called the "gnomonic |
31
|
|
|
|
|
|
|
** projection" and the "central projection". |
32
|
|
|
|
|
|
|
** |
33
|
|
|
|
|
|
|
** 2) The eta axis points due north in the adopted coordinate system. |
34
|
|
|
|
|
|
|
** If the spherical coordinates are observed (RA,Dec), the tangent |
35
|
|
|
|
|
|
|
** plane coordinates (xi,eta) are conventionally called the |
36
|
|
|
|
|
|
|
** "standard coordinates". If the spherical coordinates are with |
37
|
|
|
|
|
|
|
** respect to a right-handed triad, (xi,eta) are also right-handed. |
38
|
|
|
|
|
|
|
** The units of (xi,eta) are, effectively, radians at the tangent |
39
|
|
|
|
|
|
|
** point. |
40
|
|
|
|
|
|
|
** |
41
|
|
|
|
|
|
|
** 3) All angular arguments are in radians. |
42
|
|
|
|
|
|
|
** |
43
|
|
|
|
|
|
|
** 4) The angles a01 and a02 are returned in the range 0-2pi. The |
44
|
|
|
|
|
|
|
** angles b01 and b02 are returned in the range +/-pi, but in the |
45
|
|
|
|
|
|
|
** usual, non-pole-crossing, case, the range is +/-pi/2. |
46
|
|
|
|
|
|
|
** |
47
|
|
|
|
|
|
|
** 5) Cases where there is no solution can arise only near the poles. |
48
|
|
|
|
|
|
|
** For example, it is clearly impossible for a star at the pole |
49
|
|
|
|
|
|
|
** itself to have a non-zero xi value, and hence it is meaningless |
50
|
|
|
|
|
|
|
** to ask where the tangent point would have to be to bring about |
51
|
|
|
|
|
|
|
** this combination of xi and dec. |
52
|
|
|
|
|
|
|
** |
53
|
|
|
|
|
|
|
** 6) Also near the poles, cases can arise where there are two useful |
54
|
|
|
|
|
|
|
** solutions. The return value indicates whether the second of the |
55
|
|
|
|
|
|
|
** two solutions returned is useful; 1 indicates only one useful |
56
|
|
|
|
|
|
|
** solution, the usual case. |
57
|
|
|
|
|
|
|
** |
58
|
|
|
|
|
|
|
** 7) The basis of the algorithm is to solve the spherical triangle PSC, |
59
|
|
|
|
|
|
|
** where P is the north celestial pole, S is the star and C is the |
60
|
|
|
|
|
|
|
** tangent point. The spherical coordinates of the tangent point are |
61
|
|
|
|
|
|
|
** [a0,b0]; writing rho^2 = (xi^2+eta^2) and r^2 = (1+rho^2), side c |
62
|
|
|
|
|
|
|
** is then (pi/2-b), side p is sqrt(xi^2+eta^2) and side s (to be |
63
|
|
|
|
|
|
|
** found) is (pi/2-b0). Angle C is given by sin(C) = xi/rho and |
64
|
|
|
|
|
|
|
** cos(C) = eta/rho. Angle P (to be found) is the longitude |
65
|
|
|
|
|
|
|
** difference between star and tangent point (a-a0). |
66
|
|
|
|
|
|
|
** |
67
|
|
|
|
|
|
|
** 8) This function is a member of the following set: |
68
|
|
|
|
|
|
|
** |
69
|
|
|
|
|
|
|
** spherical vector solve for |
70
|
|
|
|
|
|
|
** |
71
|
|
|
|
|
|
|
** eraTpxes eraTpxev xi,eta |
72
|
|
|
|
|
|
|
** eraTpsts eraTpstv star |
73
|
|
|
|
|
|
|
** > eraTpors < eraTporv origin |
74
|
|
|
|
|
|
|
** |
75
|
|
|
|
|
|
|
** Called: |
76
|
|
|
|
|
|
|
** eraAnp normalize angle into range 0 to 2pi |
77
|
|
|
|
|
|
|
** |
78
|
|
|
|
|
|
|
** References: |
79
|
|
|
|
|
|
|
** |
80
|
|
|
|
|
|
|
** Calabretta M.R. & Greisen, E.W., 2002, "Representations of |
81
|
|
|
|
|
|
|
** celestial coordinates in FITS", Astron.Astrophys. 395, 1077 |
82
|
|
|
|
|
|
|
** |
83
|
|
|
|
|
|
|
** Green, R.M., "Spherical Astronomy", Cambridge University Press, |
84
|
|
|
|
|
|
|
** 1987, Chapter 13. |
85
|
|
|
|
|
|
|
** |
86
|
|
|
|
|
|
|
** Copyright (C) 2013-2019, NumFOCUS Foundation. |
87
|
|
|
|
|
|
|
** Derived, with permission, from the SOFA library. See notes at end of file. |
88
|
|
|
|
|
|
|
*/ |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
double xi2, r, sb, cb, rsb, rcb, w2, w, s, c; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
xi2 = xi*xi; |
94
|
0
|
|
|
|
|
|
r = sqrt(1.0 + xi2 + eta*eta); |
95
|
0
|
|
|
|
|
|
sb = sin(b); |
96
|
0
|
|
|
|
|
|
cb = cos(b); |
97
|
0
|
|
|
|
|
|
rsb = r*sb; |
98
|
0
|
|
|
|
|
|
rcb = r*cb; |
99
|
0
|
|
|
|
|
|
w2 = rcb*rcb - xi2; |
100
|
0
|
0
|
|
|
|
|
if ( w2 >= 0.0 ) { |
101
|
0
|
|
|
|
|
|
w = sqrt(w2); |
102
|
0
|
|
|
|
|
|
s = rsb - eta*w; |
103
|
0
|
|
|
|
|
|
c = rsb*eta + w; |
104
|
0
|
0
|
|
|
|
|
if ( xi == 0.0 && w == 0.0 ) w = 1.0; |
105
|
0
|
|
|
|
|
|
*a01 = eraAnp(a - atan2(xi,w)); |
106
|
0
|
|
|
|
|
|
*b01 = atan2(s,c); |
107
|
0
|
|
|
|
|
|
w = -w; |
108
|
0
|
|
|
|
|
|
s = rsb - eta*w; |
109
|
0
|
|
|
|
|
|
c = rsb*eta + w; |
110
|
0
|
|
|
|
|
|
*a02 = eraAnp(a - atan2(xi,w)); |
111
|
0
|
|
|
|
|
|
*b02 = atan2(s,c); |
112
|
0
|
0
|
|
|
|
|
return (fabs(rsb) < 1.0) ? 1 : 2; |
113
|
|
|
|
|
|
|
} else { |
114
|
|
|
|
|
|
|
return 0; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
/* Finished. */ |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
121
|
|
|
|
|
|
|
** |
122
|
|
|
|
|
|
|
** |
123
|
|
|
|
|
|
|
** Copyright (C) 2013-2019, NumFOCUS Foundation. |
124
|
|
|
|
|
|
|
** All rights reserved. |
125
|
|
|
|
|
|
|
** |
126
|
|
|
|
|
|
|
** This library is derived, with permission, from the International |
127
|
|
|
|
|
|
|
** Astronomical Union's "Standards of Fundamental Astronomy" library, |
128
|
|
|
|
|
|
|
** available from http://www.iausofa.org. |
129
|
|
|
|
|
|
|
** |
130
|
|
|
|
|
|
|
** The ERFA version is intended to retain identical functionality to |
131
|
|
|
|
|
|
|
** the SOFA library, but made distinct through different function and |
132
|
|
|
|
|
|
|
** file names, as set out in the SOFA license conditions. The SOFA |
133
|
|
|
|
|
|
|
** original has a role as a reference standard for the IAU and IERS, |
134
|
|
|
|
|
|
|
** and consequently redistribution is permitted only in its unaltered |
135
|
|
|
|
|
|
|
** state. The ERFA version is not subject to this restriction and |
136
|
|
|
|
|
|
|
** therefore can be included in distributions which do not support the |
137
|
|
|
|
|
|
|
** concept of "read only" software. |
138
|
|
|
|
|
|
|
** |
139
|
|
|
|
|
|
|
** Although the intent is to replicate the SOFA API (other than |
140
|
|
|
|
|
|
|
** replacement of prefix names) and results (with the exception of |
141
|
|
|
|
|
|
|
** bugs; any that are discovered will be fixed), SOFA is not |
142
|
|
|
|
|
|
|
** responsible for any errors found in this version of the library. |
143
|
|
|
|
|
|
|
** |
144
|
|
|
|
|
|
|
** If you wish to acknowledge the SOFA heritage, please acknowledge |
145
|
|
|
|
|
|
|
** that you are using a library derived from SOFA, rather than SOFA |
146
|
|
|
|
|
|
|
** itself. |
147
|
|
|
|
|
|
|
** |
148
|
|
|
|
|
|
|
** |
149
|
|
|
|
|
|
|
** TERMS AND CONDITIONS |
150
|
|
|
|
|
|
|
** |
151
|
|
|
|
|
|
|
** Redistribution and use in source and binary forms, with or without |
152
|
|
|
|
|
|
|
** modification, are permitted provided that the following conditions |
153
|
|
|
|
|
|
|
** are met: |
154
|
|
|
|
|
|
|
** |
155
|
|
|
|
|
|
|
** 1 Redistributions of source code must retain the above copyright |
156
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer. |
157
|
|
|
|
|
|
|
** |
158
|
|
|
|
|
|
|
** 2 Redistributions in binary form must reproduce the above copyright |
159
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer in |
160
|
|
|
|
|
|
|
** the documentation and/or other materials provided with the |
161
|
|
|
|
|
|
|
** distribution. |
162
|
|
|
|
|
|
|
** |
163
|
|
|
|
|
|
|
** 3 Neither the name of the Standards Of Fundamental Astronomy Board, |
164
|
|
|
|
|
|
|
** the International Astronomical Union nor the names of its |
165
|
|
|
|
|
|
|
** contributors may be used to endorse or promote products derived |
166
|
|
|
|
|
|
|
** from this software without specific prior written permission. |
167
|
|
|
|
|
|
|
** |
168
|
|
|
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
169
|
|
|
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
170
|
|
|
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
171
|
|
|
|
|
|
|
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
172
|
|
|
|
|
|
|
** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
173
|
|
|
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
174
|
|
|
|
|
|
|
** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
175
|
|
|
|
|
|
|
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
176
|
|
|
|
|
|
|
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
177
|
|
|
|
|
|
|
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
178
|
|
|
|
|
|
|
** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
179
|
|
|
|
|
|
|
** POSSIBILITY OF SUCH DAMAGE. |
180
|
|
|
|
|
|
|
** |
181
|
|
|
|
|
|
|
*/ |