1 #include "sofa.h"
2
iauTpxev(double v[3],double v0[3],double * xi,double * eta)3 int iauTpxev(double v[3], double v0[3], double *xi, double *eta)
4 /*
5 ** - - - - - - - - -
6 ** i a u 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 ** This function is part of the International Astronomical Union's
14 ** SOFA (Standards of Fundamental Astronomy) software collection.
15 **
16 ** Status: support function.
17 **
18 ** Given:
19 ** v double[3] direction cosines of star (Note 4)
20 ** v0 double[3] direction cosines of tangent point (Note 4)
21 **
22 ** Returned:
23 ** *xi,*eta double tangent plane coordinates of star
24 **
25 ** Returned (function value):
26 ** int status: 0 = OK
27 ** 1 = star too far from axis
28 ** 2 = antistar on tangent plane
29 ** 3 = antistar too far from axis
30 **
31 ** Notes:
32 **
33 ** 1) The tangent plane projection is also called the "gnomonic
34 ** projection" and the "central projection".
35 **
36 ** 2) The eta axis points due north in the adopted coordinate system.
37 ** If the direction cosines represent observed (RA,Dec), the tangent
38 ** plane coordinates (xi,eta) are conventionally called the
39 ** "standard coordinates". If the direction cosines are with
40 ** respect to a right-handed triad, (xi,eta) are also right-handed.
41 ** The units of (xi,eta) are, effectively, radians at the tangent
42 ** point.
43 **
44 ** 3) The method used is to extend the star vector to the tangent
45 ** plane and then rotate the triad so that (x,y) becomes (xi,eta).
46 ** Writing (a,b) for the celestial spherical coordinates of the
47 ** star, the sequence of rotations is (a+pi/2) around the z-axis
48 ** followed by (pi/2-b) around the x-axis.
49 **
50 ** 4) If vector v0 is not of unit length, or if vector v is of zero
51 ** length, the results will be wrong.
52 **
53 ** 5) If v0 points at a pole, the returned (xi,eta) will be based on
54 ** the arbitrary assumption that the longitude coordinate of the
55 ** tangent point is zero.
56 **
57 ** 6) This function is a member of the following set:
58 **
59 ** spherical vector solve for
60 **
61 ** iauTpxes > iauTpxev < xi,eta
62 ** iauTpsts iauTpstv star
63 ** iauTpors iauTporv origin
64 **
65 ** References:
66 **
67 ** Calabretta M.R. & Greisen, E.W., 2002, "Representations of
68 ** celestial coordinates in FITS", Astron.Astrophys. 395, 1077
69 **
70 ** Green, R.M., "Spherical Astronomy", Cambridge University Press,
71 ** 1987, Chapter 13.
72 **
73 ** This revision: 2018 January 2
74 **
75 ** SOFA release 2021-05-12
76 **
77 ** Copyright (C) 2021 IAU SOFA Board. See notes at end.
78 */
79 {
80 const double TINY = 1e-6;
81 int j;
82 double x, y, z, x0, y0, z0, r2, r, w, d;
83
84
85 /* Star and tangent point. */
86 x = v[0];
87 y = v[1];
88 z = v[2];
89 x0 = v0[0];
90 y0 = v0[1];
91 z0 = v0[2];
92
93 /* Deal with polar case. */
94 r2 = x0*x0 + y0*y0;
95 r = sqrt(r2);
96 if ( r == 0.0 ) {
97 r = 1e-20;
98 x0 = r;
99 }
100
101 /* Reciprocal of star vector length to tangent plane. */
102 w = x*x0 + y*y0;
103 d = w + z*z0;
104
105 /* Check for error cases. */
106 if ( d > TINY ) {
107 j = 0;
108 } else if ( d >= 0.0 ) {
109 j = 1;
110 d = TINY;
111 } else if ( d > -TINY ) {
112 j = 2;
113 d = -TINY;
114 } else {
115 j = 3;
116 }
117
118 /* Return the tangent plane coordinates (even in dubious cases). */
119 d *= r;
120 *xi = (y*x0 - x*y0) / d;
121 *eta = (z*r2 - z0*w) / d;
122
123 /* Return the status. */
124 return j;
125
126 /* Finished. */
127
128 /*----------------------------------------------------------------------
129 **
130 ** Copyright (C) 2021
131 ** Standards Of Fundamental Astronomy Board
132 ** of the International Astronomical Union.
133 **
134 ** =====================
135 ** SOFA Software License
136 ** =====================
137 **
138 ** NOTICE TO USER:
139 **
140 ** BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING SIX TERMS AND
141 ** CONDITIONS WHICH APPLY TO ITS USE.
142 **
143 ** 1. The Software is owned by the IAU SOFA Board ("SOFA").
144 **
145 ** 2. Permission is granted to anyone to use the SOFA software for any
146 ** purpose, including commercial applications, free of charge and
147 ** without payment of royalties, subject to the conditions and
148 ** restrictions listed below.
149 **
150 ** 3. You (the user) may copy and distribute SOFA source code to others,
151 ** and use and adapt its code and algorithms in your own software,
152 ** on a world-wide, royalty-free basis. That portion of your
153 ** distribution that does not consist of intact and unchanged copies
154 ** of SOFA source code files is a "derived work" that must comply
155 ** with the following requirements:
156 **
157 ** a) Your work shall be marked or carry a statement that it
158 ** (i) uses routines and computations derived by you from
159 ** software provided by SOFA under license to you; and
160 ** (ii) does not itself constitute software provided by and/or
161 ** endorsed by SOFA.
162 **
163 ** b) The source code of your derived work must contain descriptions
164 ** of how the derived work is based upon, contains and/or differs
165 ** from the original SOFA software.
166 **
167 ** c) The names of all routines in your derived work shall not
168 ** include the prefix "iau" or "sofa" or trivial modifications
169 ** thereof such as changes of case.
170 **
171 ** d) The origin of the SOFA components of your derived work must
172 ** not be misrepresented; you must not claim that you wrote the
173 ** original software, nor file a patent application for SOFA
174 ** software or algorithms embedded in the SOFA software.
175 **
176 ** e) These requirements must be reproduced intact in any source
177 ** distribution and shall apply to anyone to whom you have
178 ** granted a further right to modify the source code of your
179 ** derived work.
180 **
181 ** Note that, as originally distributed, the SOFA software is
182 ** intended to be a definitive implementation of the IAU standards,
183 ** and consequently third-party modifications are discouraged. All
184 ** variations, no matter how minor, must be explicitly marked as
185 ** such, as explained above.
186 **
187 ** 4. You shall not cause the SOFA software to be brought into
188 ** disrepute, either by misuse, or use for inappropriate tasks, or
189 ** by inappropriate modification.
190 **
191 ** 5. The SOFA software is provided "as is" and SOFA makes no warranty
192 ** as to its use or performance. SOFA does not and cannot warrant
193 ** the performance or results which the user may obtain by using the
194 ** SOFA software. SOFA makes no warranties, express or implied, as
195 ** to non-infringement of third party rights, merchantability, or
196 ** fitness for any particular purpose. In no event will SOFA be
197 ** liable to the user for any consequential, incidental, or special
198 ** damages, including any lost profits or lost savings, even if a
199 ** SOFA representative has been advised of such damages, or for any
200 ** claim by any third party.
201 **
202 ** 6. The provision of any version of the SOFA software under the terms
203 ** and conditions specified herein does not imply that future
204 ** versions will also be made available under the same terms and
205 ** conditions.
206 *
207 ** In any published work or commercial product which uses the SOFA
208 ** software directly, acknowledgement (see www.iausofa.org) is
209 ** appreciated.
210 **
211 ** Correspondence concerning SOFA software should be addressed as
212 ** follows:
213 **
214 ** By email: sofa@ukho.gov.uk
215 ** By post: IAU SOFA Center
216 ** HM Nautical Almanac Office
217 ** UK Hydrographic Office
218 ** Admiralty Way, Taunton
219 ** Somerset, TA1 2DN
220 ** United Kingdom
221 **
222 **--------------------------------------------------------------------*/
223 }
224