FACT++  1.0
ldn.c
Go to the documentation of this file.
1 #include "erfa.h"
2 
3 void eraLdn(int n, eraLDBODY b[], double ob[3], double sc[3],
4  double sn[3])
5 /*+
6 ** - - - - - - -
7 ** e r a L d n
8 ** - - - - - - -
9 **
10 ** For a star, apply light deflection by multiple solar-system bodies,
11 ** as part of transforming coordinate direction into natural direction.
12 **
13 ** Given:
14 ** n int number of bodies (note 1)
15 ** b eraLDBODY[n] data for each of the n bodies (Notes 1,2):
16 ** bm double mass of the body (solar masses, Note 3)
17 ** dl double deflection limiter (Note 4)
18 ** pv [2][3] barycentric PV of the body (au, au/day)
19 ** ob double[3] barycentric position of the observer (au)
20 ** sc double[3] observer to star coord direction (unit vector)
21 **
22 ** Returned:
23 ** sn double[3] observer to deflected star (unit vector)
24 **
25 ** 1) The array b contains n entries, one for each body to be
26 ** considered. If n = 0, no gravitational light deflection will be
27 ** applied, not even for the Sun.
28 **
29 ** 2) The array b should include an entry for the Sun as well as for
30 ** any planet or other body to be taken into account. The entries
31 ** should be in the order in which the light passes the body.
32 **
33 ** 3) In the entry in the b array for body i, the mass parameter
34 ** b[i].bm can, as required, be adjusted in order to allow for such
35 ** effects as quadrupole field.
36 **
37 ** 4) The deflection limiter parameter b[i].dl is phi^2/2, where phi is
38 ** the angular separation (in radians) between star and body at
39 ** which limiting is applied. As phi shrinks below the chosen
40 ** threshold, the deflection is artificially reduced, reaching zero
41 ** for phi = 0. Example values suitable for a terrestrial
42 ** observer, together with masses, are as follows:
43 **
44 ** body i b[i].bm b[i].dl
45 **
46 ** Sun 1.0 6e-6
47 ** Jupiter 0.00095435 3e-9
48 ** Saturn 0.00028574 3e-10
49 **
50 ** 5) For cases where the starlight passes the body before reaching the
51 ** observer, the body is placed back along its barycentric track by
52 ** the light time from that point to the observer. For cases where
53 ** the body is "behind" the observer no such shift is applied. If
54 ** a different treatment is preferred, the user has the option of
55 ** instead using the eraLd function. Similarly, eraLd can be used
56 ** for cases where the source is nearby, not a star.
57 **
58 ** 6) The returned vector sn is not normalized, but the consequential
59 ** departure from unit magnitude is always negligible.
60 **
61 ** 7) The arguments sc and sn can be the same array.
62 **
63 ** 8) For efficiency, validation is omitted. The supplied masses must
64 ** be greater than zero, the position and velocity vectors must be
65 ** right, and the deflection limiter greater than zero.
66 **
67 ** Reference:
68 **
69 ** Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to
70 ** the Astronomical Almanac, 3rd ed., University Science Books
71 ** (2013), Section 7.2.4.
72 **
73 ** Called:
74 ** eraCp copy p-vector
75 ** eraPdp scalar product of two p-vectors
76 ** eraPmp p-vector minus p-vector
77 ** eraPpsp p-vector plus scaled p-vector
78 ** eraPn decompose p-vector into modulus and direction
79 ** eraLd light deflection by a solar-system body
80 **
81 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
82 ** Derived, with permission, from the SOFA library. See notes at end of file.
83 */
84 {
85 /* Light time for 1 AU (days) */
86  const double CR = ERFA_AULT/ERFA_DAYSEC;
87 
88  int i;
89  double v[3], dt, ev[3], em, e[3];
90 
91 /* Star direction prior to deflection. */
92  eraCp(sc, sn);
93 
94 /* Body by body. */
95  for ( i = 0; i < n; i++ ) {
96 
97  /* Body to observer vector at epoch of observation (au). */
98  eraPmp ( ob, b[i].pv[0], v );
99 
100  /* Minus the time since the light passed the body (days). */
101  dt = eraPdp(sn,v) * CR;
102 
103  /* Neutralize if the star is "behind" the observer. */
104  dt = ERFA_GMIN(dt, 0.0);
105 
106  /* Backtrack the body to the time the light was passing the body. */
107  eraPpsp(v, -dt, b[i].pv[1], ev);
108 
109  /* Body to observer vector as magnitude and direction. */
110  eraPn(ev, &em, e);
111 
112  /* Apply light deflection for this body. */
113  eraLd ( b[i].bm, sn, sn, e, em, b[i].dl, sn );
114 
115  /* Next body. */
116  }
117 
118 /* Finished. */
119 
120 }
121 /*----------------------------------------------------------------------
122 **
123 **
124 ** Copyright (C) 2013-2015, 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 */
double eraPdp(double a[3], double b[3])
Definition: pdp.c:3
#define ERFA_AULT
Definition: erfam.h:108
void eraLd(double bm, double p[3], double q[3], double e[3], double em, double dlim, double p1[3])
Definition: ld.c:3
int i
Definition: db_dim_client.c:21
#define ERFA_DAYSEC
Definition: erfam.h:75
void eraPmp(double a[3], double b[3], double amb[3])
Definition: pmp.c:3
void eraPn(double p[3], double *r, double u[3])
Definition: pn.c:3
#define ERFA_GMIN(A, B)
Definition: erfam.h:137
void eraPpsp(double a[3], double s, double b[3], double apsb[3])
Definition: ppsp.c:3
void eraLdn(int n, eraLDBODY b[], double ob[3], double sc[3], double sn[3])
Definition: ldn.c:3
void eraCp(double p[3], double c[3])
Definition: cp.c:3