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