1 | #include "erfa.h"
|
---|
2 |
|
---|
3 | double eraPap(double a[3], double b[3])
|
---|
4 | /*
|
---|
5 | ** - - - - - - -
|
---|
6 | ** e r a P a p
|
---|
7 | ** - - - - - - -
|
---|
8 | **
|
---|
9 | ** Position-angle from two p-vectors.
|
---|
10 | **
|
---|
11 | ** Given:
|
---|
12 | ** a double[3] direction of reference point
|
---|
13 | ** b double[3] direction of point whose PA is required
|
---|
14 | **
|
---|
15 | ** Returned (function value):
|
---|
16 | ** double position angle of b with respect to a (radians)
|
---|
17 | **
|
---|
18 | ** Notes:
|
---|
19 | **
|
---|
20 | ** 1) The result is the position angle, in radians, of direction b with
|
---|
21 | ** respect to direction a. It is in the range -pi to +pi. The
|
---|
22 | ** sense is such that if b is a small distance "north" of a the
|
---|
23 | ** position angle is approximately zero, and if b is a small
|
---|
24 | ** distance "east" of a the position angle is approximately +pi/2.
|
---|
25 | **
|
---|
26 | ** 2) The vectors a and b need not be of unit length.
|
---|
27 | **
|
---|
28 | ** 3) Zero is returned if the two directions are the same or if either
|
---|
29 | ** vector is null.
|
---|
30 | **
|
---|
31 | ** 4) If vector a is at a pole, the result is ill-defined.
|
---|
32 | **
|
---|
33 | ** Called:
|
---|
34 | ** eraPn decompose p-vector into modulus and direction
|
---|
35 | ** eraPm modulus of p-vector
|
---|
36 | ** eraPxp vector product of two p-vectors
|
---|
37 | ** eraPmp p-vector minus p-vector
|
---|
38 | ** eraPdp scalar product of two p-vectors
|
---|
39 | **
|
---|
40 | ** Copyright (C) 2013-2017, NumFOCUS Foundation.
|
---|
41 | ** Derived, with permission, from the SOFA library. See notes at end of file.
|
---|
42 | */
|
---|
43 | {
|
---|
44 | double am, au[3], bm, st, ct, xa, ya, za, eta[3], xi[3], a2b[3], pa;
|
---|
45 |
|
---|
46 |
|
---|
47 | /* Modulus and direction of the a vector. */
|
---|
48 | eraPn(a, &am, au);
|
---|
49 |
|
---|
50 | /* Modulus of the b vector. */
|
---|
51 | bm = eraPm(b);
|
---|
52 |
|
---|
53 | /* Deal with the case of a null vector. */
|
---|
54 | if ((am == 0.0) || (bm == 0.0)) {
|
---|
55 | st = 0.0;
|
---|
56 | ct = 1.0;
|
---|
57 | } else {
|
---|
58 |
|
---|
59 | /* The "north" axis tangential from a (arbitrary length). */
|
---|
60 | xa = a[0];
|
---|
61 | ya = a[1];
|
---|
62 | za = a[2];
|
---|
63 | eta[0] = -xa * za;
|
---|
64 | eta[1] = -ya * za;
|
---|
65 | eta[2] = xa*xa + ya*ya;
|
---|
66 |
|
---|
67 | /* The "east" axis tangential from a (same length). */
|
---|
68 | eraPxp(eta, au, xi);
|
---|
69 |
|
---|
70 | /* The vector from a to b. */
|
---|
71 | eraPmp(b, a, a2b);
|
---|
72 |
|
---|
73 | /* Resolve into components along the north and east axes. */
|
---|
74 | st = eraPdp(a2b, xi);
|
---|
75 | ct = eraPdp(a2b, eta);
|
---|
76 |
|
---|
77 | /* Deal with degenerate cases. */
|
---|
78 | if ((st == 0.0) && (ct == 0.0)) ct = 1.0;
|
---|
79 | }
|
---|
80 |
|
---|
81 | /* Position angle. */
|
---|
82 | pa = atan2(st, ct);
|
---|
83 |
|
---|
84 | return pa;
|
---|
85 |
|
---|
86 | }
|
---|
87 | /*----------------------------------------------------------------------
|
---|
88 | **
|
---|
89 | **
|
---|
90 | ** Copyright (C) 2013-2017, NumFOCUS Foundation.
|
---|
91 | ** All rights reserved.
|
---|
92 | **
|
---|
93 | ** This library is derived, with permission, from the International
|
---|
94 | ** Astronomical Union's "Standards of Fundamental Astronomy" library,
|
---|
95 | ** available from http://www.iausofa.org.
|
---|
96 | **
|
---|
97 | ** The ERFA version is intended to retain identical functionality to
|
---|
98 | ** the SOFA library, but made distinct through different function and
|
---|
99 | ** file names, as set out in the SOFA license conditions. The SOFA
|
---|
100 | ** original has a role as a reference standard for the IAU and IERS,
|
---|
101 | ** and consequently redistribution is permitted only in its unaltered
|
---|
102 | ** state. The ERFA version is not subject to this restriction and
|
---|
103 | ** therefore can be included in distributions which do not support the
|
---|
104 | ** concept of "read only" software.
|
---|
105 | **
|
---|
106 | ** Although the intent is to replicate the SOFA API (other than
|
---|
107 | ** replacement of prefix names) and results (with the exception of
|
---|
108 | ** bugs; any that are discovered will be fixed), SOFA is not
|
---|
109 | ** responsible for any errors found in this version of the library.
|
---|
110 | **
|
---|
111 | ** If you wish to acknowledge the SOFA heritage, please acknowledge
|
---|
112 | ** that you are using a library derived from SOFA, rather than SOFA
|
---|
113 | ** itself.
|
---|
114 | **
|
---|
115 | **
|
---|
116 | ** TERMS AND CONDITIONS
|
---|
117 | **
|
---|
118 | ** Redistribution and use in source and binary forms, with or without
|
---|
119 | ** modification, are permitted provided that the following conditions
|
---|
120 | ** are met:
|
---|
121 | **
|
---|
122 | ** 1 Redistributions of source code must retain the above copyright
|
---|
123 | ** notice, this list of conditions and the following disclaimer.
|
---|
124 | **
|
---|
125 | ** 2 Redistributions in binary form must reproduce the above copyright
|
---|
126 | ** notice, this list of conditions and the following disclaimer in
|
---|
127 | ** the documentation and/or other materials provided with the
|
---|
128 | ** distribution.
|
---|
129 | **
|
---|
130 | ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
|
---|
131 | ** the International Astronomical Union nor the names of its
|
---|
132 | ** contributors may be used to endorse or promote products derived
|
---|
133 | ** from this software without specific prior written permission.
|
---|
134 | **
|
---|
135 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
136 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
137 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
138 | ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
139 | ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
140 | ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
---|
141 | ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
142 | ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
143 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
144 | ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
---|
145 | ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
146 | ** POSSIBILITY OF SUCH DAMAGE.
|
---|
147 | **
|
---|
148 | */
|
---|