celes 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +32 -0
  4. data/README.md +179 -0
  5. data/Rakefile +1 -0
  6. data/celes.gemspec +22 -0
  7. data/ext/celes/a2af.c +120 -0
  8. data/ext/celes/a2tf.c +116 -0
  9. data/ext/celes/af2a.c +107 -0
  10. data/ext/celes/anp.c +82 -0
  11. data/ext/celes/anpm.c +82 -0
  12. data/ext/celes/bi00.c +116 -0
  13. data/ext/celes/bp00.c +173 -0
  14. data/ext/celes/bp06.c +136 -0
  15. data/ext/celes/bpn2xy.c +100 -0
  16. data/ext/celes/c2i00a.c +139 -0
  17. data/ext/celes/c2i00b.c +139 -0
  18. data/ext/celes/c2i06a.c +136 -0
  19. data/ext/celes/c2ibpn.c +142 -0
  20. data/ext/celes/c2ixy.c +131 -0
  21. data/ext/celes/c2ixys.c +123 -0
  22. data/ext/celes/c2s.c +96 -0
  23. data/ext/celes/c2t00a.c +154 -0
  24. data/ext/celes/c2t00b.c +150 -0
  25. data/ext/celes/c2t06a.c +152 -0
  26. data/ext/celes/c2tcio.c +122 -0
  27. data/ext/celes/c2teqx.c +122 -0
  28. data/ext/celes/c2tpe.c +167 -0
  29. data/ext/celes/c2txy.c +159 -0
  30. data/ext/celes/cal2jd.c +139 -0
  31. data/ext/celes/celes_core.c +2522 -0
  32. data/ext/celes/cp.c +80 -0
  33. data/ext/celes/cpv.c +82 -0
  34. data/ext/celes/cr.c +83 -0
  35. data/ext/celes/d2dtf.c +206 -0
  36. data/ext/celes/d2tf.c +160 -0
  37. data/ext/celes/dat.c +289 -0
  38. data/ext/celes/depend +25 -0
  39. data/ext/celes/dtdb.c +1213 -0
  40. data/ext/celes/dtf2d.c +196 -0
  41. data/ext/celes/ee00.c +128 -0
  42. data/ext/celes/ee00a.c +135 -0
  43. data/ext/celes/ee00b.c +141 -0
  44. data/ext/celes/ee06a.c +122 -0
  45. data/ext/celes/eect00.c +282 -0
  46. data/ext/celes/eform.c +147 -0
  47. data/ext/celes/eo06a.c +131 -0
  48. data/ext/celes/eors.c +108 -0
  49. data/ext/celes/epb.c +96 -0
  50. data/ext/celes/epb2jd.c +91 -0
  51. data/ext/celes/epj.c +93 -0
  52. data/ext/celes/epj2jd.c +91 -0
  53. data/ext/celes/epv00.c +2589 -0
  54. data/ext/celes/eqeq94.c +131 -0
  55. data/ext/celes/era00.c +136 -0
  56. data/ext/celes/extconf.rb +4 -0
  57. data/ext/celes/fad03.c +103 -0
  58. data/ext/celes/fae03.c +102 -0
  59. data/ext/celes/faf03.c +106 -0
  60. data/ext/celes/faju03.c +102 -0
  61. data/ext/celes/fal03.c +103 -0
  62. data/ext/celes/falp03.c +103 -0
  63. data/ext/celes/fama03.c +102 -0
  64. data/ext/celes/fame03.c +102 -0
  65. data/ext/celes/fane03.c +99 -0
  66. data/ext/celes/faom03.c +104 -0
  67. data/ext/celes/fapa03.c +103 -0
  68. data/ext/celes/fasa03.c +102 -0
  69. data/ext/celes/faur03.c +99 -0
  70. data/ext/celes/fave03.c +102 -0
  71. data/ext/celes/fk52h.c +143 -0
  72. data/ext/celes/fk5hip.c +126 -0
  73. data/ext/celes/fk5hz.c +160 -0
  74. data/ext/celes/fw2m.c +134 -0
  75. data/ext/celes/fw2xy.c +120 -0
  76. data/ext/celes/gc2gd.c +134 -0
  77. data/ext/celes/gc2gde.c +200 -0
  78. data/ext/celes/gd2gc.c +134 -0
  79. data/ext/celes/gd2gce.c +138 -0
  80. data/ext/celes/gmst00.c +145 -0
  81. data/ext/celes/gmst06.c +136 -0
  82. data/ext/celes/gmst82.c +151 -0
  83. data/ext/celes/gst00a.c +138 -0
  84. data/ext/celes/gst00b.c +146 -0
  85. data/ext/celes/gst06.c +140 -0
  86. data/ext/celes/gst06a.c +131 -0
  87. data/ext/celes/gst94.c +131 -0
  88. data/ext/celes/h2fk5.c +148 -0
  89. data/ext/celes/hfk5z.c +175 -0
  90. data/ext/celes/ir.c +83 -0
  91. data/ext/celes/jd2cal.c +155 -0
  92. data/ext/celes/jdcalf.c +161 -0
  93. data/ext/celes/num00a.c +121 -0
  94. data/ext/celes/num00b.c +121 -0
  95. data/ext/celes/num06a.c +125 -0
  96. data/ext/celes/numat.c +109 -0
  97. data/ext/celes/nut00a.c +2047 -0
  98. data/ext/celes/nut00b.c +372 -0
  99. data/ext/celes/nut06a.c +153 -0
  100. data/ext/celes/nut80.c +325 -0
  101. data/ext/celes/nutm80.c +117 -0
  102. data/ext/celes/obl06.c +118 -0
  103. data/ext/celes/obl80.c +118 -0
  104. data/ext/celes/p06e.c +321 -0
  105. data/ext/celes/p2pv.c +83 -0
  106. data/ext/celes/p2s.c +91 -0
  107. data/ext/celes/pap.c +139 -0
  108. data/ext/celes/pas.c +96 -0
  109. data/ext/celes/pb06.c +144 -0
  110. data/ext/celes/pdp.c +84 -0
  111. data/ext/celes/pfw06.c +165 -0
  112. data/ext/celes/plan94.c +514 -0
  113. data/ext/celes/pm.c +83 -0
  114. data/ext/celes/pmat00.c +118 -0
  115. data/ext/celes/pmat06.c +122 -0
  116. data/ext/celes/pmat76.c +141 -0
  117. data/ext/celes/pmp.c +85 -0
  118. data/ext/celes/pn.c +109 -0
  119. data/ext/celes/pn00.c +177 -0
  120. data/ext/celes/pn00a.c +162 -0
  121. data/ext/celes/pn00b.c +162 -0
  122. data/ext/celes/pn06.c +187 -0
  123. data/ext/celes/pn06a.c +152 -0
  124. data/ext/celes/pnm00a.c +121 -0
  125. data/ext/celes/pnm00b.c +121 -0
  126. data/ext/celes/pnm06a.c +124 -0
  127. data/ext/celes/pnm80.c +126 -0
  128. data/ext/celes/pom00.c +115 -0
  129. data/ext/celes/ppp.c +85 -0
  130. data/ext/celes/ppsp.c +94 -0
  131. data/ext/celes/pr00.c +142 -0
  132. data/ext/celes/prec76.c +148 -0
  133. data/ext/celes/pv2p.c +81 -0
  134. data/ext/celes/pv2s.c +144 -0
  135. data/ext/celes/pvdpv.c +102 -0
  136. data/ext/celes/pvm.c +86 -0
  137. data/ext/celes/pvmpv.c +87 -0
  138. data/ext/celes/pvppv.c +87 -0
  139. data/ext/celes/pvstar.c +207 -0
  140. data/ext/celes/pvu.c +93 -0
  141. data/ext/celes/pvup.c +88 -0
  142. data/ext/celes/pvxpv.c +107 -0
  143. data/ext/celes/pxp.c +94 -0
  144. data/ext/celes/rm2v.c +111 -0
  145. data/ext/celes/rv2m.c +118 -0
  146. data/ext/celes/rx.c +110 -0
  147. data/ext/celes/rxp.c +99 -0
  148. data/ext/celes/rxpv.c +86 -0
  149. data/ext/celes/rxr.c +99 -0
  150. data/ext/celes/ry.c +110 -0
  151. data/ext/celes/rz.c +110 -0
  152. data/ext/celes/s00.c +371 -0
  153. data/ext/celes/s00a.c +143 -0
  154. data/ext/celes/s00b.c +143 -0
  155. data/ext/celes/s06.c +368 -0
  156. data/ext/celes/s06a.c +145 -0
  157. data/ext/celes/s2c.c +85 -0
  158. data/ext/celes/s2p.c +88 -0
  159. data/ext/celes/s2pv.c +103 -0
  160. data/ext/celes/s2xpv.c +87 -0
  161. data/ext/celes/sepp.c +105 -0
  162. data/ext/celes/seps.c +93 -0
  163. data/ext/celes/sofa.h +379 -0
  164. data/ext/celes/sofam.h +155 -0
  165. data/ext/celes/sp00.c +118 -0
  166. data/ext/celes/starpm.c +205 -0
  167. data/ext/celes/starpv.c +264 -0
  168. data/ext/celes/sxp.c +84 -0
  169. data/ext/celes/sxpv.c +85 -0
  170. data/ext/celes/taitt.c +110 -0
  171. data/ext/celes/taiut1.c +112 -0
  172. data/ext/celes/taiutc.c +182 -0
  173. data/ext/celes/tcbtdb.c +132 -0
  174. data/ext/celes/tcgtt.c +109 -0
  175. data/ext/celes/tdbtcb.c +137 -0
  176. data/ext/celes/tdbtt.c +122 -0
  177. data/ext/celes/tf2a.c +107 -0
  178. data/ext/celes/tf2d.c +107 -0
  179. data/ext/celes/tr.c +93 -0
  180. data/ext/celes/trxp.c +93 -0
  181. data/ext/celes/trxpv.c +93 -0
  182. data/ext/celes/tttai.c +110 -0
  183. data/ext/celes/tttcg.c +112 -0
  184. data/ext/celes/tttdb.c +121 -0
  185. data/ext/celes/ttut1.c +110 -0
  186. data/ext/celes/ut1tai.c +111 -0
  187. data/ext/celes/ut1tt.c +110 -0
  188. data/ext/celes/ut1utc.c +193 -0
  189. data/ext/celes/utctai.c +163 -0
  190. data/ext/celes/utcut1.c +151 -0
  191. data/ext/celes/xy06.c +2758 -0
  192. data/ext/celes/xys00a.c +133 -0
  193. data/ext/celes/xys00b.c +133 -0
  194. data/ext/celes/xys06a.c +133 -0
  195. data/ext/celes/zp.c +77 -0
  196. data/ext/celes/zpv.c +79 -0
  197. data/ext/celes/zr.c +83 -0
  198. data/lib/celes.rb +6 -0
  199. data/lib/celes/version.rb +3 -0
  200. data/sofa_20120301.diff +31384 -0
  201. data/test/t_sofa.rb +8228 -0
  202. metadata +251 -0
@@ -0,0 +1,84 @@
1
+ #include "sofam.h"
2
+
3
+ double iauPdp(double a[3], double b[3])
4
+ /*
5
+ ** - - - - - - -
6
+ ** i a u P d p
7
+ ** - - - - - - -
8
+ **
9
+ ** p-vector inner (=scalar=dot) product.
10
+ **
11
+ ** Status: vector/matrix support function.
12
+ **
13
+ ** Given:
14
+ ** a double[3] first p-vector
15
+ ** b double[3] second p-vector
16
+ **
17
+ ** Returned (function value):
18
+ ** double a . b
19
+ **
20
+ ** This revision: 2008 May 22
21
+ **
22
+ ** Original version 2012-03-01
23
+ **
24
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
25
+ */
26
+ {
27
+ double w;
28
+
29
+
30
+ w = a[0] * b[0]
31
+ + a[1] * b[1]
32
+ + a[2] * b[2];
33
+
34
+ return w;
35
+
36
+ /*----------------------------------------------------------------------
37
+ **
38
+ ** Celes is a wrapper of the SOFA Library for Ruby.
39
+ **
40
+ ** This file is redistributed and relicensed in accordance with
41
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
42
+ **
43
+ ** The original library is available from IAU Standards of
44
+ ** Fundamental Astronomy (http://www.iausofa.org/).
45
+ **
46
+ **
47
+ **
48
+ **
49
+ **
50
+ ** Copyright (C) 2013, Naoki Arita
51
+ ** All rights reserved.
52
+ **
53
+ ** Redistribution and use in source and binary forms, with or without
54
+ ** modification, are permitted provided that the following conditions
55
+ ** are met:
56
+ **
57
+ ** 1 Redistributions of source code must retain the above copyright
58
+ ** notice, this list of conditions and the following disclaimer.
59
+ **
60
+ ** 2 Redistributions in binary form must reproduce the above copyright
61
+ ** notice, this list of conditions and the following disclaimer in
62
+ ** the documentation and/or other materials provided with the
63
+ ** distribution.
64
+ **
65
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
66
+ ** the International Astronomical Union nor the names of its
67
+ ** contributors may be used to endorse or promote products derived
68
+ ** from this software without specific prior written permission.
69
+ **
70
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
73
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
74
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
75
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
76
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
77
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
79
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
80
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
81
+ ** POSSIBILITY OF SUCH DAMAGE.
82
+ **
83
+ **--------------------------------------------------------------------*/
84
+ }
@@ -0,0 +1,165 @@
1
+ #include "sofam.h"
2
+
3
+ void iauPfw06(double date1, double date2,
4
+ double *gamb, double *phib, double *psib, double *epsa)
5
+ /*
6
+ ** - - - - - - - - -
7
+ ** i a u P f w 0 6
8
+ ** - - - - - - - - -
9
+ **
10
+ ** Precession angles, IAU 2006 (Fukushima-Williams 4-angle formulation).
11
+ **
12
+ ** Status: canonical model.
13
+ **
14
+ ** Given:
15
+ ** date1,date2 double TT as a 2-part Julian Date (Note 1)
16
+ **
17
+ ** Returned:
18
+ ** gamb double F-W angle gamma_bar (radians)
19
+ ** phib double F-W angle phi_bar (radians)
20
+ ** psib double F-W angle psi_bar (radians)
21
+ ** epsa double F-W angle epsilon_A (radians)
22
+ **
23
+ ** Notes:
24
+ **
25
+ ** 1) The TT date date1+date2 is a Julian Date, apportioned in any
26
+ ** convenient way between the two arguments. For example,
27
+ ** JD(TT)=2450123.7 could be expressed in any of these ways,
28
+ ** among others:
29
+ **
30
+ ** date1 date2
31
+ **
32
+ ** 2450123.7 0.0 (JD method)
33
+ ** 2451545.0 -1421.3 (J2000 method)
34
+ ** 2400000.5 50123.2 (MJD method)
35
+ ** 2450123.5 0.2 (date & time method)
36
+ **
37
+ ** The JD method is the most natural and convenient to use in
38
+ ** cases where the loss of several decimal digits of resolution
39
+ ** is acceptable. The J2000 method is best matched to the way
40
+ ** the argument is handled internally and will deliver the
41
+ ** optimum resolution. The MJD method and the date & time methods
42
+ ** are both good compromises between resolution and convenience.
43
+ **
44
+ ** 2) Naming the following points:
45
+ **
46
+ ** e = J2000.0 ecliptic pole,
47
+ ** p = GCRS pole,
48
+ ** E = mean ecliptic pole of date,
49
+ ** and P = mean pole of date,
50
+ **
51
+ ** the four Fukushima-Williams angles are as follows:
52
+ **
53
+ ** gamb = gamma_bar = epE
54
+ ** phib = phi_bar = pE
55
+ ** psib = psi_bar = pEP
56
+ ** epsa = epsilon_A = EP
57
+ **
58
+ ** 3) The matrix representing the combined effects of frame bias and
59
+ ** precession is:
60
+ **
61
+ ** PxB = R_1(-epsa).R_3(-psib).R_1(phib).R_3(gamb)
62
+ **
63
+ ** 4) The matrix representing the combined effects of frame bias,
64
+ ** precession and nutation is simply:
65
+ **
66
+ ** NxPxB = R_1(-epsa-dE).R_3(-psib-dP).R_1(phib).R_3(gamb)
67
+ **
68
+ ** where dP and dE are the nutation components with respect to the
69
+ ** ecliptic of date.
70
+ **
71
+ ** Reference:
72
+ **
73
+ ** Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
74
+ **
75
+ ** Called:
76
+ ** iauObl06 mean obliquity, IAU 2006
77
+ **
78
+ ** This revision: 2009 December 17
79
+ **
80
+ ** Original version 2012-03-01
81
+ **
82
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
83
+ */
84
+ {
85
+ double t;
86
+
87
+
88
+ /* Interval between fundamental date J2000.0 and given date (JC). */
89
+ t = ((date1 - DJ00) + date2) / DJC;
90
+
91
+ /* P03 bias+precession angles. */
92
+ *gamb = ( -0.052928 +
93
+ ( 10.556378 +
94
+ ( 0.4932044 +
95
+ ( -0.00031238 +
96
+ ( -0.000002788 +
97
+ ( 0.0000000260 )
98
+ * t) * t) * t) * t) * t) * DAS2R;
99
+ *phib = ( 84381.412819 +
100
+ ( -46.811016 +
101
+ ( 0.0511268 +
102
+ ( 0.00053289 +
103
+ ( -0.000000440 +
104
+ ( -0.0000000176 )
105
+ * t) * t) * t) * t) * t) * DAS2R;
106
+ *psib = ( -0.041775 +
107
+ ( 5038.481484 +
108
+ ( 1.5584175 +
109
+ ( -0.00018522 +
110
+ ( -0.000026452 +
111
+ ( -0.0000000148 )
112
+ * t) * t) * t) * t) * t) * DAS2R;
113
+ *epsa = iauObl06(date1, date2);
114
+
115
+ return;
116
+
117
+ /*----------------------------------------------------------------------
118
+ **
119
+ ** Celes is a wrapper of the SOFA Library for Ruby.
120
+ **
121
+ ** This file is redistributed and relicensed in accordance with
122
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
123
+ **
124
+ ** The original library is available from IAU Standards of
125
+ ** Fundamental Astronomy (http://www.iausofa.org/).
126
+ **
127
+ **
128
+ **
129
+ **
130
+ **
131
+ ** Copyright (C) 2013, Naoki Arita
132
+ ** All rights reserved.
133
+ **
134
+ ** Redistribution and use in source and binary forms, with or without
135
+ ** modification, are permitted provided that the following conditions
136
+ ** are met:
137
+ **
138
+ ** 1 Redistributions of source code must retain the above copyright
139
+ ** notice, this list of conditions and the following disclaimer.
140
+ **
141
+ ** 2 Redistributions in binary form must reproduce the above copyright
142
+ ** notice, this list of conditions and the following disclaimer in
143
+ ** the documentation and/or other materials provided with the
144
+ ** distribution.
145
+ **
146
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
147
+ ** the International Astronomical Union nor the names of its
148
+ ** contributors may be used to endorse or promote products derived
149
+ ** from this software without specific prior written permission.
150
+ **
151
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
152
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
153
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
154
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
155
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
156
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
157
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
158
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
159
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
160
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
161
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
162
+ ** POSSIBILITY OF SUCH DAMAGE.
163
+ **
164
+ **--------------------------------------------------------------------*/
165
+ }
@@ -0,0 +1,514 @@
1
+ #include "sofam.h"
2
+
3
+ int iauPlan94(double date1, double date2, int np, double pv[2][3])
4
+ /*
5
+ ** - - - - - - - - - -
6
+ ** i a u P l a n 9 4
7
+ ** - - - - - - - - - -
8
+ **
9
+ ** Status: support function.
10
+ **
11
+ ** Approximate heliocentric position and velocity of a nominated major
12
+ ** planet: Mercury, Venus, EMB, Mars, Jupiter, Saturn, Uranus or
13
+ ** Neptune (but not the Earth itself).
14
+ **
15
+ ** Given:
16
+ ** date1 double TDB date part A (Note 1)
17
+ ** date2 double TDB date part B (Note 1)
18
+ ** np int planet (1=Mercury, 2=Venus, 3=EMB, 4=Mars,
19
+ ** 5=Jupiter, 6=Saturn, 7=Uranus, 8=Neptune)
20
+ **
21
+ ** Returned (argument):
22
+ ** pv double[2][3] planet p,v (heliocentric, J2000.0, AU,AU/d)
23
+ **
24
+ ** Returned (function value):
25
+ ** int status: -1 = illegal NP (outside 1-8)
26
+ ** 0 = OK
27
+ ** +1 = warning: year outside 1000-3000
28
+ ** +2 = warning: failed to converge
29
+ **
30
+ ** Notes:
31
+ **
32
+ ** 1) The date date1+date2 is in the TDB time scale (in practice TT can
33
+ ** be used) and is a Julian Date, apportioned in any convenient way
34
+ ** between the two arguments. For example, JD(TDB)=2450123.7 could
35
+ ** be expressed in any of these ways, among others:
36
+ **
37
+ ** date1 date2
38
+ **
39
+ ** 2450123.7 0.0 (JD method)
40
+ ** 2451545.0 -1421.3 (J2000 method)
41
+ ** 2400000.5 50123.2 (MJD method)
42
+ ** 2450123.5 0.2 (date & time method)
43
+ **
44
+ ** The JD method is the most natural and convenient to use in cases
45
+ ** where the loss of several decimal digits of resolution is
46
+ ** acceptable. The J2000 method is best matched to the way the
47
+ ** argument is handled internally and will deliver the optimum
48
+ ** resolution. The MJD method and the date & time methods are both
49
+ ** good compromises between resolution and convenience. The limited
50
+ ** accuracy of the present algorithm is such that any of the methods
51
+ ** is satisfactory.
52
+ **
53
+ ** 2) If an np value outside the range 1-8 is supplied, an error status
54
+ ** (function value -1) is returned and the pv vector set to zeroes.
55
+ **
56
+ ** 3) For np=3 the result is for the Earth-Moon Barycenter. To obtain
57
+ ** the heliocentric position and velocity of the Earth, use instead
58
+ ** the SOFA function iauEpv00.
59
+ **
60
+ ** 4) On successful return, the array pv contains the following:
61
+ **
62
+ ** pv[0][0] x }
63
+ ** pv[0][1] y } heliocentric position, AU
64
+ ** pv[0][2] z }
65
+ **
66
+ ** pv[1][0] xdot }
67
+ ** pv[1][1] ydot } heliocentric velocity, AU/d
68
+ ** pv[1][2] zdot }
69
+ **
70
+ ** The reference frame is equatorial and is with respect to the
71
+ ** mean equator and equinox of epoch J2000.0.
72
+ **
73
+ ** 5) The algorithm is due to J.L. Simon, P. Bretagnon, J. Chapront,
74
+ ** M. Chapront-Touze, G. Francou and J. Laskar (Bureau des
75
+ ** Longitudes, Paris, France). From comparisons with JPL
76
+ ** ephemeris DE102, they quote the following maximum errors
77
+ ** over the interval 1800-2050:
78
+ **
79
+ ** L (arcsec) B (arcsec) R (km)
80
+ **
81
+ ** Mercury 4 1 300
82
+ ** Venus 5 1 800
83
+ ** EMB 6 1 1000
84
+ ** Mars 17 1 7700
85
+ ** Jupiter 71 5 76000
86
+ ** Saturn 81 13 267000
87
+ ** Uranus 86 7 712000
88
+ ** Neptune 11 1 253000
89
+ **
90
+ ** Over the interval 1000-3000, they report that the accuracy is no
91
+ ** worse than 1.5 times that over 1800-2050. Outside 1000-3000 the
92
+ ** accuracy declines.
93
+ **
94
+ ** Comparisons of the present function with the JPL DE200 ephemeris
95
+ ** give the following RMS errors over the interval 1960-2025:
96
+ **
97
+ ** position (km) velocity (m/s)
98
+ **
99
+ ** Mercury 334 0.437
100
+ ** Venus 1060 0.855
101
+ ** EMB 2010 0.815
102
+ ** Mars 7690 1.98
103
+ ** Jupiter 71700 7.70
104
+ ** Saturn 199000 19.4
105
+ ** Uranus 564000 16.4
106
+ ** Neptune 158000 14.4
107
+ **
108
+ ** Comparisons against DE200 over the interval 1800-2100 gave the
109
+ ** following maximum absolute differences. (The results using
110
+ ** DE406 were essentially the same.)
111
+ **
112
+ ** L (arcsec) B (arcsec) R (km) Rdot (m/s)
113
+ **
114
+ ** Mercury 7 1 500 0.7
115
+ ** Venus 7 1 1100 0.9
116
+ ** EMB 9 1 1300 1.0
117
+ ** Mars 26 1 9000 2.5
118
+ ** Jupiter 78 6 82000 8.2
119
+ ** Saturn 87 14 263000 24.6
120
+ ** Uranus 86 7 661000 27.4
121
+ ** Neptune 11 2 248000 21.4
122
+ **
123
+ ** 6) The present SOFA re-implementation of the original Simon et al.
124
+ ** Fortran code differs from the original in the following respects:
125
+ **
126
+ ** * C instead of Fortran.
127
+ **
128
+ ** * The date is supplied in two parts.
129
+ **
130
+ ** * The result is returned only in equatorial Cartesian form;
131
+ ** the ecliptic longitude, latitude and radius vector are not
132
+ ** returned.
133
+ **
134
+ ** * The result is in the J2000.0 equatorial frame, not ecliptic.
135
+ **
136
+ ** * More is done in-line: there are fewer calls to subroutines.
137
+ **
138
+ ** * Different error/warning status values are used.
139
+ **
140
+ ** * A different Kepler's-equation-solver is used (avoiding
141
+ ** use of double precision complex).
142
+ **
143
+ ** * Polynomials in t are nested to minimize rounding errors.
144
+ **
145
+ ** * Explicit double constants are used to avoid mixed-mode
146
+ ** expressions.
147
+ **
148
+ ** None of the above changes affects the result significantly.
149
+ **
150
+ ** 7) The returned status indicates the most serious condition
151
+ ** encountered during execution of the function. Illegal np is
152
+ ** considered the most serious, overriding failure to converge,
153
+ ** which in turn takes precedence over the remote date warning.
154
+ **
155
+ ** Called:
156
+ ** iauAnp normalize angle into range 0 to 2pi
157
+ **
158
+ ** Reference: Simon, J.L, Bretagnon, P., Chapront, J.,
159
+ ** Chapront-Touze, M., Francou, G., and Laskar, J.,
160
+ ** Astron. Astrophys. 282, 663 (1994).
161
+ **
162
+ ** This revision: 2012 March 8
163
+ **
164
+ ** Original version 2012-03-01
165
+ **
166
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
167
+ */
168
+ {
169
+ /* Gaussian constant */
170
+ static const double GK = 0.017202098950;
171
+
172
+ /* Sin and cos of J2000.0 mean obliquity (IAU 1976) */
173
+ static const double SINEPS = 0.3977771559319137;
174
+ static const double COSEPS = 0.9174820620691818;
175
+
176
+ /* Maximum number of iterations allowed to solve Kepler's equation */
177
+ static const int KMAX = 10;
178
+
179
+ int jstat, i, k;
180
+ double t, da, dl, de, dp, di, dom, dmu, arga, argl, am,
181
+ ae, dae, ae2, at, r, v, si2, xq, xp, tl, xsw,
182
+ xcw, xm2, xf, ci2, xms, xmc, xpxq2, x, y, z;
183
+
184
+ /* Planetary inverse masses */
185
+ static const double amas[] = { 6023600.0, /* Mercury */
186
+ 408523.5, /* Venus */
187
+ 328900.5, /* EMB */
188
+ 3098710.0, /* Mars */
189
+ 1047.355, /* Jupiter */
190
+ 3498.5, /* Saturn */
191
+ 22869.0, /* Uranus */
192
+ 19314.0 }; /* Neptune */
193
+
194
+ /*
195
+ ** Tables giving the mean Keplerian elements, limited to t^2 terms:
196
+ **
197
+ ** a semi-major axis (AU)
198
+ ** dlm mean longitude (degree and arcsecond)
199
+ ** e eccentricity
200
+ ** pi longitude of the perihelion (degree and arcsecond)
201
+ ** dinc inclination (degree and arcsecond)
202
+ ** omega longitude of the ascending node (degree and arcsecond)
203
+ */
204
+
205
+ static const double a[][3] = {
206
+ { 0.3870983098, 0.0, 0.0 }, /* Mercury */
207
+ { 0.7233298200, 0.0, 0.0 }, /* Venus */
208
+ { 1.0000010178, 0.0, 0.0 }, /* EMB */
209
+ { 1.5236793419, 3e-10, 0.0 }, /* Mars */
210
+ { 5.2026032092, 19132e-10, -39e-10 }, /* Jupiter */
211
+ { 9.5549091915, -0.0000213896, 444e-10 }, /* Saturn */
212
+ { 19.2184460618, -3716e-10, 979e-10 }, /* Uranus */
213
+ { 30.1103868694, -16635e-10, 686e-10 } /* Neptune */
214
+ };
215
+
216
+ static const double dlm[][3] = {
217
+ { 252.25090552, 5381016286.88982, -1.92789 },
218
+ { 181.97980085, 2106641364.33548, 0.59381 },
219
+ { 100.46645683, 1295977422.83429, -2.04411 },
220
+ { 355.43299958, 689050774.93988, 0.94264 },
221
+ { 34.35151874, 109256603.77991, -30.60378 },
222
+ { 50.07744430, 43996098.55732, 75.61614 },
223
+ { 314.05500511, 15424811.93933, -1.75083 },
224
+ { 304.34866548, 7865503.20744, 0.21103 }
225
+ };
226
+
227
+ static const double e[][3] = {
228
+ { 0.2056317526, 0.0002040653, -28349e-10 },
229
+ { 0.0067719164, -0.0004776521, 98127e-10 },
230
+ { 0.0167086342, -0.0004203654, -0.0000126734 },
231
+ { 0.0934006477, 0.0009048438, -80641e-10 },
232
+ { 0.0484979255, 0.0016322542, -0.0000471366 },
233
+ { 0.0555481426, -0.0034664062, -0.0000643639 },
234
+ { 0.0463812221, -0.0002729293, 0.0000078913 },
235
+ { 0.0094557470, 0.0000603263, 0.0 }
236
+ };
237
+
238
+ static const double pi[][3] = {
239
+ { 77.45611904, 5719.11590, -4.83016 },
240
+ { 131.56370300, 175.48640, -498.48184 },
241
+ { 102.93734808, 11612.35290, 53.27577 },
242
+ { 336.06023395, 15980.45908, -62.32800 },
243
+ { 14.33120687, 7758.75163, 259.95938 },
244
+ { 93.05723748, 20395.49439, 190.25952 },
245
+ { 173.00529106, 3215.56238, -34.09288 },
246
+ { 48.12027554, 1050.71912, 27.39717 }
247
+ };
248
+
249
+ static const double dinc[][3] = {
250
+ { 7.00498625, -214.25629, 0.28977 },
251
+ { 3.39466189, -30.84437, -11.67836 },
252
+ { 0.0, 469.97289, -3.35053 },
253
+ { 1.84972648, -293.31722, -8.11830 },
254
+ { 1.30326698, -71.55890, 11.95297 },
255
+ { 2.48887878, 91.85195, -17.66225 },
256
+ { 0.77319689, -60.72723, 1.25759 },
257
+ { 1.76995259, 8.12333, 0.08135 }
258
+ };
259
+
260
+ static const double omega[][3] = {
261
+ { 48.33089304, -4515.21727, -31.79892 },
262
+ { 76.67992019, -10008.48154, -51.32614 },
263
+ { 174.87317577, -8679.27034, 15.34191 },
264
+ { 49.55809321, -10620.90088, -230.57416 },
265
+ { 100.46440702, 6362.03561, 326.52178 },
266
+ { 113.66550252, -9240.19942, -66.23743 },
267
+ { 74.00595701, 2669.15033, 145.93964 },
268
+ { 131.78405702, -221.94322, -0.78728 }
269
+ };
270
+
271
+ /* Tables for trigonometric terms to be added to the mean elements of */
272
+ /* the semi-major axes */
273
+
274
+ static const double kp[][9] = {
275
+ { 69613, 75645, 88306, 59899, 15746, 71087, 142173, 3086, 0 },
276
+ { 21863, 32794, 26934, 10931, 26250, 43725, 53867, 28939, 0 },
277
+ { 16002, 21863, 32004, 10931, 14529, 16368, 15318, 32794, 0 },
278
+ { 6345, 7818, 15636, 7077, 8184, 14163, 1107, 4872, 0 },
279
+ { 1760, 1454, 1167, 880, 287, 2640, 19, 2047, 1454 },
280
+ { 574, 0, 880, 287, 19, 1760, 1167, 306, 574 },
281
+ { 204, 0, 177, 1265, 4, 385, 200, 208, 204 },
282
+ { 0, 102, 106, 4, 98, 1367, 487, 204, 0 }
283
+ };
284
+
285
+ static const double ca[][9] = {
286
+ { 4, -13, 11, -9, -9, -3, -1, 4, 0 },
287
+ { -156, 59, -42, 6, 19, -20, -10, -12, 0 },
288
+ { 64, -152, 62, -8, 32, -41, 19, -11, 0 },
289
+ { 124, 621, -145, 208, 54, -57, 30, 15, 0 },
290
+ { -23437, -2634, 6601, 6259, -1507,-1821, 2620, -2115, -1489 },
291
+ { 62911,-119919, 79336,17814,-24241,12068, 8306, -4893, 8902 },
292
+ { 389061,-262125,-44088, 8387,-22976,-2093, -615, -9720, 6633 },
293
+ { -412235,-157046,-31430,37817, -9740, -13, -7449, 9644, 0 }
294
+ };
295
+
296
+ static const double sa[][9] = {
297
+ { -29, -1, 9, 6, -6, 5, 4, 0, 0 },
298
+ { -48, -125, -26, -37, 18, -13, -20, -2, 0 },
299
+ { -150, -46, 68, 54, 14, 24, -28, 22, 0 },
300
+ { -621, 532, -694, -20, 192, -94, 71, -73, 0 },
301
+ { -14614,-19828, -5869, 1881, -4372, -2255, 782, 930, 913 },
302
+ { 139737, 0, 24667, 51123, -5102, 7429, -4095, -1976, -9566 },
303
+ { -138081, 0, 37205,-49039,-41901,-33872,-27037,-12474, 18797 },
304
+ { 0, 28492,133236, 69654, 52322,-49577,-26430, -3593, 0 }
305
+ };
306
+
307
+ /* Tables giving the trigonometric terms to be added to the mean */
308
+ /* elements of the mean longitudes */
309
+
310
+ static const double kq[][10] = {
311
+ { 3086,15746,69613,59899,75645,88306, 12661, 2658, 0, 0 },
312
+ { 21863,32794,10931, 73, 4387,26934, 1473, 2157, 0, 0 },
313
+ { 10,16002,21863,10931, 1473,32004, 4387, 73, 0, 0 },
314
+ { 10, 6345, 7818, 1107,15636, 7077, 8184, 532, 10, 0 },
315
+ { 19, 1760, 1454, 287, 1167, 880, 574, 2640, 19, 1454 },
316
+ { 19, 574, 287, 306, 1760, 12, 31, 38, 19, 574 },
317
+ { 4, 204, 177, 8, 31, 200, 1265, 102, 4, 204 },
318
+ { 4, 102, 106, 8, 98, 1367, 487, 204, 4, 102 }
319
+ };
320
+
321
+ static const double cl[][10] = {
322
+ { 21, -95, -157, 41, -5, 42, 23, 30, 0, 0 },
323
+ { -160, -313, -235, 60, -74, -76, -27, 34, 0, 0 },
324
+ { -325, -322, -79, 232, -52, 97, 55, -41, 0, 0 },
325
+ { 2268, -979, 802, 602, -668, -33, 345, 201, -55, 0 },
326
+ { 7610, -4997,-7689,-5841,-2617, 1115,-748,-607, 6074, 354 },
327
+ { -18549, 30125,20012, -730, 824, 23,1289,-352, -14767, -2062 },
328
+ { -135245,-14594, 4197,-4030,-5630,-2898,2540,-306, 2939, 1986 },
329
+ { 89948, 2103, 8963, 2695, 3682, 1648, 866,-154, -1963, -283 }
330
+ };
331
+
332
+ static const double sl[][10] = {
333
+ { -342, 136, -23, 62, 66, -52, -33, 17, 0, 0 },
334
+ { 524, -149, -35, 117, 151, 122, -71, -62, 0, 0 },
335
+ { -105, -137, 258, 35, -116, -88,-112, -80, 0, 0 },
336
+ { 854, -205, -936, -240, 140, -341, -97, -232, 536, 0 },
337
+ { -56980, 8016, 1012, 1448,-3024,-3710, 318, 503, 3767, 577 },
338
+ { 138606,-13478,-4964, 1441,-1319,-1482, 427, 1236, -9167, -1918 },
339
+ { 71234,-41116, 5334,-4935,-1848, 66, 434, -1748, 3780, -701 },
340
+ { -47645, 11647, 2166, 3194, 679, 0,-244, -419, -2531, 48 }
341
+ };
342
+
343
+ /*--------------------------------------------------------------------*/
344
+
345
+ /* Validate the planet number. */
346
+ if ((np < 1) || (np > 8)) {
347
+ jstat = -1;
348
+
349
+ /* Reset the result in case of failure. */
350
+ for (k = 0; k < 2; k++) {
351
+ for (i = 0; i < 3; i++) {
352
+ pv[k][i] = 0.0;
353
+ }
354
+ }
355
+
356
+ } else {
357
+
358
+ /* Decrement the planet number to start at zero. */
359
+ np--;
360
+
361
+ /* Time: Julian millennia since J2000.0. */
362
+ t = ((date1 - DJ00) + date2) / DJM;
363
+
364
+ /* OK status unless remote date. */
365
+ jstat = fabs(t) <= 1.0 ? 0 : 1;
366
+
367
+ /* Compute the mean elements. */
368
+ da = a[np][0] +
369
+ (a[np][1] +
370
+ a[np][2] * t) * t;
371
+ dl = (3600.0 * dlm[np][0] +
372
+ (dlm[np][1] +
373
+ dlm[np][2] * t) * t) * DAS2R;
374
+ de = e[np][0] +
375
+ ( e[np][1] +
376
+ e[np][2] * t) * t;
377
+ dp = iauAnpm((3600.0 * pi[np][0] +
378
+ (pi[np][1] +
379
+ pi[np][2] * t) * t) * DAS2R);
380
+ di = (3600.0 * dinc[np][0] +
381
+ (dinc[np][1] +
382
+ dinc[np][2] * t) * t) * DAS2R;
383
+ dom = iauAnpm((3600.0 * omega[np][0] +
384
+ (omega[np][1] +
385
+ omega[np][2] * t) * t) * DAS2R);
386
+
387
+ /* Apply the trigonometric terms. */
388
+ dmu = 0.35953620 * t;
389
+ for (k = 0; k < 8; k++) {
390
+ arga = kp[np][k] * dmu;
391
+ argl = kq[np][k] * dmu;
392
+ da += (ca[np][k] * cos(arga) +
393
+ sa[np][k] * sin(arga)) * 1e-7;
394
+ dl += (cl[np][k] * cos(argl) +
395
+ sl[np][k] * sin(argl)) * 1e-7;
396
+ }
397
+ arga = kp[np][8] * dmu;
398
+ da += t * (ca[np][8] * cos(arga) +
399
+ sa[np][8] * sin(arga)) * 1e-7;
400
+ for (k = 8; k < 10; k++) {
401
+ argl = kq[np][k] * dmu;
402
+ dl += t * (cl[np][k] * cos(argl) +
403
+ sl[np][k] * sin(argl)) * 1e-7;
404
+ }
405
+ dl = fmod(dl, D2PI);
406
+
407
+ /* Iterative soln. of Kepler's equation to get eccentric anomaly. */
408
+ am = dl - dp;
409
+ ae = am + de * sin(am);
410
+ k = 0;
411
+ dae = 1.0;
412
+ while (k < KMAX && fabs(dae) > 1e-12) {
413
+ dae = (am - ae + de * sin(ae)) / (1.0 - de * cos(ae));
414
+ ae += dae;
415
+ k++;
416
+ if (k == KMAX-1) jstat = 2;
417
+ }
418
+
419
+ /* True anomaly. */
420
+ ae2 = ae / 2.0;
421
+ at = 2.0 * atan2(sqrt((1.0 + de) / (1.0 - de)) * sin(ae2),
422
+ cos(ae2));
423
+
424
+ /* Distance (AU) and speed (radians per day). */
425
+ r = da * (1.0 - de * cos(ae));
426
+ v = GK * sqrt((1.0 + 1.0 / amas[np]) / (da * da * da));
427
+
428
+ si2 = sin(di / 2.0);
429
+ xq = si2 * cos(dom);
430
+ xp = si2 * sin(dom);
431
+ tl = at + dp;
432
+ xsw = sin(tl);
433
+ xcw = cos(tl);
434
+ xm2 = 2.0 * (xp * xcw - xq * xsw);
435
+ xf = da / sqrt(1 - de * de);
436
+ ci2 = cos(di / 2.0);
437
+ xms = (de * sin(dp) + xsw) * xf;
438
+ xmc = (de * cos(dp) + xcw) * xf;
439
+ xpxq2 = 2 * xp * xq;
440
+
441
+ /* Position (J2000.0 ecliptic x,y,z in AU). */
442
+ x = r * (xcw - xm2 * xp);
443
+ y = r * (xsw + xm2 * xq);
444
+ z = r * (-xm2 * ci2);
445
+
446
+ /* Rotate to equatorial. */
447
+ pv[0][0] = x;
448
+ pv[0][1] = y * COSEPS - z * SINEPS;
449
+ pv[0][2] = y * SINEPS + z * COSEPS;
450
+
451
+ /* Velocity (J2000.0 ecliptic xdot,ydot,zdot in AU/d). */
452
+ x = v * (( -1.0 + 2.0 * xp * xp) * xms + xpxq2 * xmc);
453
+ y = v * (( 1.0 - 2.0 * xq * xq) * xmc - xpxq2 * xms);
454
+ z = v * (2.0 * ci2 * (xp * xms + xq * xmc));
455
+
456
+ /* Rotate to equatorial. */
457
+ pv[1][0] = x;
458
+ pv[1][1] = y * COSEPS - z * SINEPS;
459
+ pv[1][2] = y * SINEPS + z * COSEPS;
460
+
461
+ }
462
+
463
+ /* Return the status. */
464
+ return jstat;
465
+
466
+ /*----------------------------------------------------------------------
467
+ **
468
+ ** Celes is a wrapper of the SOFA Library for Ruby.
469
+ **
470
+ ** This file is redistributed and relicensed in accordance with
471
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
472
+ **
473
+ ** The original library is available from IAU Standards of
474
+ ** Fundamental Astronomy (http://www.iausofa.org/).
475
+ **
476
+ **
477
+ **
478
+ **
479
+ **
480
+ ** Copyright (C) 2013, Naoki Arita
481
+ ** All rights reserved.
482
+ **
483
+ ** Redistribution and use in source and binary forms, with or without
484
+ ** modification, are permitted provided that the following conditions
485
+ ** are met:
486
+ **
487
+ ** 1 Redistributions of source code must retain the above copyright
488
+ ** notice, this list of conditions and the following disclaimer.
489
+ **
490
+ ** 2 Redistributions in binary form must reproduce the above copyright
491
+ ** notice, this list of conditions and the following disclaimer in
492
+ ** the documentation and/or other materials provided with the
493
+ ** distribution.
494
+ **
495
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
496
+ ** the International Astronomical Union nor the names of its
497
+ ** contributors may be used to endorse or promote products derived
498
+ ** from this software without specific prior written permission.
499
+ **
500
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
501
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
502
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
503
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
504
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
505
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
506
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
507
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
508
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
509
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
510
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
511
+ ** POSSIBILITY OF SUCH DAMAGE.
512
+ **
513
+ **--------------------------------------------------------------------*/
514
+ }