-
Notifications
You must be signed in to change notification settings - Fork 105
/
swephlib.c
4634 lines (4488 loc) · 161 KB
/
swephlib.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* SWISSEPH
SWISSEPH modules that may be useful for other applications
e.g. chopt.c, venus.c, swetest.c
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
coordinate transformations
obliquity of ecliptic
nutation
precession
delta t
sidereal time
setting or getting of tidal acceleration of moon
chebyshew interpolation
ephemeris file name generation
cyclic redundancy checksum CRC
modulo and normalization functions
**************************************************************/
/* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU Affero General Public License (AGPL)
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the AGPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the AGPL or a compatible license.
See https://www.gnu.org/licenses/agpl-3.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#include <string.h>
#include <ctype.h>
#include "swephexp.h"
#include "sweph.h"
#include "swephlib.h"
#if MSDOS
# include <process.h>
# define strdup _strdup
#endif
#ifdef TRACE
void swi_open_trace(char *serr);
TLS FILE *swi_fp_trace_c = NULL;
TLS FILE *swi_fp_trace_out = NULL;
TLS int32 swi_trace_count = 0;
#endif
static void init_crc32(void);
static int init_dt(void);
static double adjust_for_tidacc(double ans, double Y, double tid_acc, double tid_acc0, AS_BOOL adjust_after_1955);
static double deltat_espenak_meeus_1620(double tjd, double tid_acc);
static double deltat_stephenson_etc_2016(double tjd, double tid_acc);
static double deltat_longterm_morrison_stephenson(double tjd);
static double deltat_stephenson_morrison_2004_1600(double tjd, double tid_acc);
static double deltat_stephenson_morrison_1997_1600(double tjd, double tid_acc);
static double deltat_aa(double tjd, double tid_acc);
#define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH)
/* Reduce x modulo 360 degrees
*/
double CALL_CONV swe_degnorm(double x)
{
double y;
y = fmod(x, 360.0);
if (fabs(y) < 1e-13) y = 0; /* Alois fix 11-dec-1999 */
if( y < 0.0 ) y += 360.0;
return(y);
}
/* Reduce x modulo TWOPI degrees
*/
double CALL_CONV swe_radnorm(double x)
{
double y;
y = fmod(x, TWOPI);
if (fabs(y) < 1e-13) y = 0; /* Alois fix 11-dec-1999 */
if( y < 0.0 ) y += TWOPI;
return(y);
}
double CALL_CONV swe_deg_midp(double x1, double x0)
{
double d, y;
d = swe_difdeg2n(x1, x0); /* arc from x0 to x1 */
y = swe_degnorm(x0 + d / 2);
return(y);
}
double CALL_CONV swe_rad_midp(double x1, double x0)
{
return DEGTORAD * swe_deg_midp(x1 * RADTODEG, x0 * RADTODEG);
}
/* Reduce x modulo 2*PI
*/
double swi_mod2PI(double x)
{
double y;
y = fmod(x, TWOPI);
if( y < 0.0 ) y += TWOPI;
return(y);
}
double swi_angnorm(double x)
{
if (x < 0.0 )
return x + TWOPI;
else if (x >= TWOPI)
return x - TWOPI;
else
return x;
}
void swi_cross_prod(double *a, double *b, double *x)
{
x[0] = a[1]*b[2] - a[2]*b[1];
x[1] = a[2]*b[0] - a[0]*b[2];
x[2] = a[0]*b[1] - a[1]*b[0];
}
/* Evaluates a given chebyshev series coef[0..ncf-1]
* with ncf terms at x in [-1,1]. Communications of the ACM, algorithm 446,
* April 1973 (vol. 16 no.4) by Dr. Roger Broucke.
*/
double swi_echeb(double x, double *coef, int ncf)
{
int j;
double x2, br, brp2, brpp;
x2 = x * 2.;
br = 0.;
brp2 = 0.; /* dummy assign to silence gcc warning */
brpp = 0.;
for (j = ncf - 1; j >= 0; j--) {
brp2 = brpp;
brpp = br;
br = x2 * brpp - brp2 + coef[j];
}
return (br - brp2) * .5;
}
/*
* evaluates derivative of chebyshev series, see echeb
*/
double swi_edcheb(double x, double *coef, int ncf)
{
double bjpl, xjpl;
int j;
double x2, bf, bj, dj, xj, bjp2, xjp2;
x2 = x * 2.;
bf = 0.; /* dummy assign to silence gcc warning */
bj = 0.; /* dummy assign to silence gcc warning */
xjp2 = 0.;
xjpl = 0.;
bjp2 = 0.;
bjpl = 0.;
for (j = ncf - 1; j >= 1; j--) {
dj = (double) (j + j);
xj = coef[j] * dj + xjp2;
bj = x2 * bjpl - bjp2 + xj;
bf = bjp2;
bjp2 = bjpl;
bjpl = bj;
xjp2 = xjpl;
xjpl = xj;
}
return (bj - bf) * .5;
}
/*
* conversion between ecliptical and equatorial polar coordinates.
* for users of SWISSEPH, not used by our routines.
* for ecl. to equ. eps must be negative.
* for equ. to ecl. eps must be positive.
* xpo, xpn are arrays of 3 doubles containing position.
* attention: input must be in degrees!
*/
void CALL_CONV swe_cotrans(double *xpo, double *xpn, double eps)
{
int i;
double x[6], e = eps * DEGTORAD;
for(i = 0; i <= 1; i++)
x[i] = xpo[i];
x[0] *= DEGTORAD;
x[1] *= DEGTORAD;
x[2] = 1;
for(i = 3; i <= 5; i++)
x[i] = 0;
swi_polcart(x, x);
swi_coortrf(x, x, e);
swi_cartpol(x, x);
xpn[0] = x[0] * RADTODEG;
xpn[1] = x[1] * RADTODEG;
xpn[2] = xpo[2];
}
/*
* conversion between ecliptical and equatorial polar coordinates
* with speed.
* for users of SWISSEPH, not used by our routines.
* for ecl. to equ. eps must be negative.
* for equ. to ecl. eps must be positive.
* xpo, xpn are arrays of 6 doubles containing position and speed.
* attention: input must be in degrees!
*/
void CALL_CONV swe_cotrans_sp(double *xpo, double *xpn, double eps)
{
int i;
double x[6], e = eps * DEGTORAD;
for (i = 0; i <= 5; i++)
x[i] = xpo[i];
x[0] *= DEGTORAD;
x[1] *= DEGTORAD;
x[2] = 1; /* avoids problems with polcart(), if x[2] = 0 */
x[3] *= DEGTORAD;
x[4] *= DEGTORAD;
swi_polcart_sp(x, x);
swi_coortrf(x, x, e);
swi_coortrf(x+3, x+3, e);
swi_cartpol_sp(x, xpn);
xpn[0] *= RADTODEG;
xpn[1] *= RADTODEG;
xpn[2] = xpo[2];
xpn[3] *= RADTODEG;
xpn[4] *= RADTODEG;
xpn[5] = xpo[5];
}
/*
* conversion between ecliptical and equatorial cartesian coordinates
* for ecl. to equ. eps must be negative
* for equ. to ecl. eps must be positive
*/
void swi_coortrf(double *xpo, double *xpn, double eps)
{
double sineps, coseps;
double x[3];
sineps = sin(eps);
coseps = cos(eps);
x[0] = xpo[0];
x[1] = xpo[1] * coseps + xpo[2] * sineps;
x[2] = -xpo[1] * sineps + xpo[2] * coseps;
xpn[0] = x[0];
xpn[1] = x[1];
xpn[2] = x[2];
}
/*
* conversion between ecliptical and equatorial cartesian coordinates
* sineps sin(eps)
* coseps cos(eps)
* for ecl. to equ. sineps must be -sin(eps)
*/
void swi_coortrf2(double *xpo, double *xpn, double sineps, double coseps)
{
double x[3];
x[0] = xpo[0];
x[1] = xpo[1] * coseps + xpo[2] * sineps;
x[2] = -xpo[1] * sineps + xpo[2] * coseps;
xpn[0] = x[0];
xpn[1] = x[1];
xpn[2] = x[2];
}
/* conversion of cartesian (x[3]) to polar coordinates (l[3]).
* x = l is allowed.
* if |x| = 0, then lon, lat and rad := 0.
*/
void swi_cartpol(double *x, double *l)
{
double rxy;
double ll[3];
if (x[0] == 0 && x[1] == 0 && x[2] == 0) {
l[0] = l[1] = l[2] = 0;
return;
}
rxy = x[0]*x[0] + x[1]*x[1];
ll[2] = sqrt(rxy + x[2]*x[2]);
rxy = sqrt(rxy);
ll[0] = atan2(x[1], x[0]);
if (ll[0] < 0.0) ll[0] += TWOPI;
if (rxy == 0) {
if (x[2] >= 0)
ll[1] = PI / 2;
else
ll[1] = -(PI / 2);
} else {
ll[1] = atan(x[2] / rxy);
}
l[0] = ll[0];
l[1] = ll[1];
l[2] = ll[2];
}
/* conversion from polar (l[3]) to cartesian coordinates (x[3]).
* x = l is allowed.
*/
void swi_polcart(double *l, double *x)
{
double xx[3];
double cosl1;
cosl1 = cos(l[1]);
xx[0] = l[2] * cosl1 * cos(l[0]);
xx[1] = l[2] * cosl1 * sin(l[0]);
xx[2] = l[2] * sin(l[1]);
x[0] = xx[0];
x[1] = xx[1];
x[2] = xx[2];
}
/* conversion of position and speed.
* from cartesian (x[6]) to polar coordinates (l[6]).
* x = l is allowed.
* if position is 0, function returns direction of
* motion.
*/
void swi_cartpol_sp(double *x, double *l)
{
int i;
double xx[6], ll[6];
double rxy, coslon, sinlon, coslat, sinlat;
/* zero position */
if (x[0] == 0 && x[1] == 0 && x[2] == 0) {
ll[0] = ll[1] = ll[3] = ll[4] = 0;
ll[5] = sqrt(square_sum((x+3)));
swi_cartpol(x+3, ll);
ll[2] = 0;
for (i = 0; i <= 5; i++)
l[i] = ll[i];
return;
}
/* zero speed */
if (x[3] == 0 && x[4] == 0 && x[5] == 0) {
l[3] = l[4] = l[5] = 0;
swi_cartpol(x, l);
return;
}
/* position */
rxy = x[0]*x[0] + x[1]*x[1];
ll[2] = sqrt(rxy + x[2]*x[2]);
rxy = sqrt(rxy);
ll[0] = atan2(x[1], x[0]);
if (ll[0] < 0.0) ll[0] += TWOPI;
ll[1] = atan(x[2] / rxy);
/* speed:
* 1. rotate coordinate system by longitude of position about z-axis,
* so that new x-axis = position radius projected onto x-y-plane.
* in the new coordinate system
* vy'/r = dlong/dt, where r = sqrt(x^2 +y^2).
* 2. rotate coordinate system by latitude about new y-axis.
* vz"/r = dlat/dt, where r = position radius.
* vx" = dr/dt
*/
coslon = x[0] / rxy; /* cos(l[0]); */
sinlon = x[1] / rxy; /* sin(l[0]); */
coslat = rxy / ll[2]; /* cos(l[1]); */
sinlat = x[2] / ll[2]; /* sin(ll[1]); */
xx[3] = x[3] * coslon + x[4] * sinlon;
xx[4] = -x[3] * sinlon + x[4] * coslon;
l[3] = xx[4] / rxy; /* speed in longitude */
xx[4] = -sinlat * xx[3] + coslat * x[5];
xx[5] = coslat * xx[3] + sinlat * x[5];
l[4] = xx[4] / ll[2]; /* speed in latitude */
l[5] = xx[5]; /* speed in radius */
l[0] = ll[0]; /* return position */
l[1] = ll[1];
l[2] = ll[2];
}
/* conversion of position and speed
* from polar (l[6]) to cartesian coordinates (x[6])
* x = l is allowed
* explanation s. swi_cartpol_sp()
*/
void swi_polcart_sp(double *l, double *x)
{
double sinlon, coslon, sinlat, coslat;
double xx[6], rxy, rxyz;
/* zero speed */
if (l[3] == 0 && l[4] == 0 && l[5] == 0) {
x[3] = x[4] = x[5] = 0;
swi_polcart(l, x);
return;
}
/* position */
coslon = cos(l[0]);
sinlon = sin(l[0]);
coslat = cos(l[1]);
sinlat = sin(l[1]);
xx[0] = l[2] * coslat * coslon;
xx[1] = l[2] * coslat * sinlon;
xx[2] = l[2] * sinlat;
/* speed; explanation s. swi_cartpol_sp(), same method the other way round*/
rxyz = l[2];
rxy = sqrt(xx[0] * xx[0] + xx[1] * xx[1]);
xx[5] = l[5];
xx[4] = l[4] * rxyz;
x[5] = sinlat * xx[5] + coslat * xx[4]; /* speed z */
xx[3] = coslat * xx[5] - sinlat * xx[4];
xx[4] = l[3] * rxy;
x[3] = coslon * xx[3] - sinlon * xx[4]; /* speed x */
x[4] = sinlon * xx[3] + coslon * xx[4]; /* speed y */
x[0] = xx[0]; /* return position */
x[1] = xx[1];
x[2] = xx[2];
}
double swi_dot_prod_unit(double *x, double *y)
{
double dop = x[0]*y[0]+x[1]*y[1]+x[2]*y[2];
double e1 = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
double e2 = sqrt(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]);
dop /= e1;
dop /= e2;
if (dop > 1)
dop = 1;
if (dop < -1)
dop = -1;
return dop;
}
/* functions for precession and ecliptic obliquity according to Vondrák et alii, 2011 */
#define AS2R (DEGTORAD / 3600.0)
#define D2PI TWOPI
#define EPS0 (84381.406 * AS2R)
#define NPOL_PEPS 4
#define NPER_PEPS 10
#define NPOL_PECL 4
#define NPER_PECL 8
#define NPOL_PEQU 4
#define NPER_PEQU 14
/* for pre_peps(): */
/* polynomials */
static const double pepol[NPOL_PEPS][2] = {
{+8134.017132, +84028.206305},
{+5043.0520035, +0.3624445},
{-0.00710733, -0.00004039},
{+0.000000271, -0.000000110}
};
/* periodics */
static const double peper[5][NPER_PEPS] = {
{+409.90, +396.15, +537.22, +402.90, +417.15, +288.92, +4043.00, +306.00, +277.00, +203.00},
{-6908.287473, -3198.706291, +1453.674527, -857.748557, +1173.231614, -156.981465, +371.836550, -216.619040, +193.691479, +11.891524},
{+753.872780, -247.805823, +379.471484, -53.880558, -90.109153, -353.600190, -63.115353, -28.248187, +17.703387, +38.911307},
{-2845.175469, +449.844989, -1255.915323, +886.736783, +418.887514, +997.912441, -240.979710, +76.541307, -36.788069, -170.964086},
{-1704.720302, -862.308358, +447.832178, -889.571909, +190.402846, -56.564991, -296.222622, -75.859952, +67.473503, +3.014055}
};
/* for pre_pecl(): */
/* polynomials */
static const double pqpol[NPOL_PECL][2] = {
{+5851.607687, -1600.886300},
{-0.1189000, +1.1689818},
{-0.00028913, -0.00000020},
{+0.000000101, -0.000000437}
};
/* periodics */
static const double pqper[5][NPER_PECL] = {
{708.15, 2309, 1620, 492.2, 1183, 622, 882, 547},
{-5486.751211, -17.127623, -617.517403, 413.44294, 78.614193, -180.732815, -87.676083, 46.140315},
// original publication A&A 534, A22 (2011):
//{-684.66156, 2446.28388, 399.671049, -356.652376, -186.387003, -316.80007, 198.296071, 101.135679},
// typo fixed according to A&A 541, C1 (2012)
{-684.66156, 2446.28388, 399.671049, -356.652376, -186.387003, -316.80007, 198.296701, 101.135679},
{667.66673, -2354.886252, -428.152441, 376.202861, 184.778874, 335.321713, -185.138669, -120.97283},
{-5523.863691, -549.74745, -310.998056, 421.535876, -36.776172, -145.278396, -34.74445, 22.885731}
};
/* for pre_pequ(): */
/* polynomials */
static const double xypol[NPOL_PEQU][2] = {
{+5453.282155, -73750.930350},
{+0.4252841, -0.7675452},
{-0.00037173, -0.00018725},
{-0.000000152, +0.000000231}
};
/* periodics */
static const double xyper[5][NPER_PEQU] = {
{256.75, 708.15, 274.2, 241.45, 2309, 492.2, 396.1, 288.9, 231.1, 1610, 620, 157.87, 220.3, 1200},
{-819.940624, -8444.676815, 2600.009459, 2755.17563, -167.659835, 871.855056, 44.769698, -512.313065, -819.415595, -538.071099, -189.793622, -402.922932, 179.516345, -9.814756},
{75004.344875, 624.033993, 1251.136893, -1102.212834, -2660.66498, 699.291817, 153.16722, -950.865637, 499.754645, -145.18821, 558.116553, -23.923029, -165.405086, 9.344131},
{81491.287984, 787.163481, 1251.296102, -1257.950837, -2966.79973, 639.744522, 131.600209, -445.040117, 584.522874, -89.756563, 524.42963, -13.549067, -210.157124, -44.919798},
{1558.515853, 7774.939698, -2219.534038, -2523.969396, 247.850422, -846.485643, -1393.124055, 368.526116, 749.045012, 444.704518, 235.934465, 374.049623, -171.33018, -22.899655}
};
void swi_ldp_peps(double tjd, double *dpre, double *deps)
{
int i;
int npol = NPOL_PEPS;
int nper = NPER_PEPS;
double t, p, q, w, a, s, c;
t = (tjd - J2000) / 36525.0;
p = 0;
q = 0;
/* periodic terms */
for (i = 0; i < nper; i++) {
w = D2PI * t;
a = w / peper[0][i];
s = sin(a);
c = cos(a);
p += c * peper[1][i] + s * peper[3][i];
q += c * peper[2][i] + s * peper[4][i];
}
/* polynomial terms */
w = 1;
for (i = 0; i < npol; i++) {
p += pepol[i][0] * w;
q += pepol[i][1] * w;
w *= t;
}
/* both to radians */
p *= AS2R;
q *= AS2R;
/* return */
if (dpre != NULL)
*dpre = p;
if (deps != NULL)
*deps = q;
//fprintf(stderr, "%.17f\n", *deps / DEGTORAD);
}
/*
* Long term high precision precession,
* according to Vondrak/Capitaine/Wallace, "New precession expressions, valid
* for long time intervals", in A&A 534, A22(2011).
*/
/* precession of the ecliptic */
static void pre_pecl(double tjd, double *vec)
{
int i;
int npol = NPOL_PECL;
int nper = NPER_PECL;
double t, p, q, w, a, s, c, z;
t = (tjd - J2000) / 36525.0;
p = 0;
q = 0;
/* periodic terms */
for (i = 0; i < nper; i++) {
w = D2PI * t;
a = w / pqper[0][i];
s = sin(a);
c = cos(a);
p += c * pqper[1][i] + s * pqper[3][i];
q += c * pqper[2][i] + s * pqper[4][i];
}
/* polynomial terms */
w = 1;
for (i = 0; i < npol; i++) {
p += pqpol[i][0] * w;
q += pqpol[i][1] * w;
w *= t;
}
/* both to radians */
p *= AS2R;
q *= AS2R;
/* ecliptic pole vector */
z = 1 - p * p - q * q;
if (z < 0)
z = 0;
else
z = sqrt(z);
s = sin(EPS0);
c = cos(EPS0);
vec[0] = p;
vec[1] = - q * c - z * s;
vec[2] = - q * s + z * c;
}
/* precession of the equator */
static void pre_pequ(double tjd, double *veq)
{
int i;
int npol = NPOL_PEQU;
int nper = NPER_PEQU;
double t, x, y, w, a, s, c;
t = (tjd - J2000) / 36525.0;
x = 0;
y = 0;
for (i = 0; i < nper; i++) {
w = D2PI * t;
a = w / xyper[0][i];
s = sin(a);
c = cos(a);
x += c * xyper[1][i] + s * xyper[3][i];
y += c * xyper[2][i] + s * xyper[4][i];
}
/* polynomial terms */
w = 1;
for (i = 0; i < npol; i++) {
x += xypol[i][0] * w;
y += xypol[i][1] * w;
w *= t;
}
x *= AS2R;
y *= AS2R;
/* equator pole vector */
veq[0] = x;
veq[1] = y;
w = x * x + y * y;
if (w < 1)
veq[2] = sqrt(1 - w);
else
veq[2] = 0;
}
#if 0
static void swi_cross_prod(double *a, double *b, double *x)
{
x[0] = a[1] * b[2] - a[2] * b[1];
x[1] = a[2] * b[0] - a[0] * b[2];
x[2] = a[0] * b[1] - a[1] * b[0];
}
#endif
/* precession matrix */
static void pre_pmat(double tjd, double *rp)
{
double peqr[3], pecl[3], v[3], w, eqx[3];
//tjd = 1219339.078000;
/*equator pole */
pre_pequ(tjd, peqr);
/* ecliptic pole */
pre_pecl(tjd, pecl);
// fprintf(stderr, "%.17f %.17f %.17f\n", peqr[0], peqr[1], peqr[2]);
// fprintf(stderr, "%.17f %.17f %.17f\n", pecl[0], pecl[1], pecl[2]);
/* equinox */
swi_cross_prod(peqr, pecl, v);
w = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
eqx[0] = v[0] / w;
eqx[1] = v[1] / w;
eqx[2] = v[2] / w;
swi_cross_prod(peqr, eqx, v);
rp[0] = eqx[0];
rp[1] = eqx[1];
rp[2] = eqx[2];
rp[3] = v[0];
rp[4] = v[1];
rp[5] = v[2];
rp[6] = peqr[0];
rp[7] = peqr[1];
rp[8] = peqr[2];
// int i;
// for (i = 0; i < 3; i++) {
// fprintf(stderr, "(%.17f %.17f %.17f)\n", rp[i*3], rp[i*3+1],rp[i*3+2]);
// } /**/
}
/* precession according to Owen 1990:
* Owen, William M., Jr., (JPL) "A Theory of the Earth's Precession
* Relative to the Invariable Plane of the Solar System", Ph.D.
* Dissertation, University of Florida, 1990.
* Implemented for time range -18000 to 14000.
*/
/*
* p. 177: central time Tc = -160, covering time span -200 <= T <= -120
* i.e. -14000 +- 40 centuries
* p. 178: central time Tc = -80, covering time span -120 <= T <= -40
* i.e. -6000 +- 40 centuries
* p. 179: central time Tc = 0, covering time span -40 <= T <= +40
* i.e. 2000 +- 40 centuries
* p. 180: central time Tc = 80, covering time span 40 <= T <= 120
* i.e. 10000 +- 40 centuries
* p. 181: central time Tc = 160, covering time span 120 <= T <= 200
* i.e. 10000 +- 40 centuries
*/
static const double owen_eps0_coef[5][10] = {
{23.699391439256386, 5.2330816033981775e-1, -5.6259493384864815e-2, -8.2033318431602032e-3, 6.6774163554156385e-4, 2.4931584012812606e-5, -3.1313623302407878e-6, 2.0343814827951515e-7, 2.9182026615852936e-8, -4.1118760893281951e-9,},
{24.124759551704588, -1.2094875596566286e-1, -8.3914869653015218e-2, 3.5357075322387405e-3, 6.4557467824807032e-4, -2.5092064378707704e-5, -1.7631607274450848e-6, 1.3363622791424094e-7, 1.5577817511054047e-8, -2.4613907093017122e-9,},
{23.439103144206208, -4.9386077073143590e-1, -2.3965445283267805e-4, 8.6637485629656489e-3, -5.2828151901367600e-5, -4.3951004595359217e-5, -1.1058785949914705e-6, 6.2431490022621172e-8, 3.4725376218710764e-8, 1.3658853127005757e-9,},
{22.724671295125046, -1.6041813558650337e-1, 7.0646783888132504e-2, 1.4967806745062837e-3, -6.6857270989190734e-4, 5.7578378071604775e-6, 3.3738508454638728e-6, -2.2917813537654764e-7, -2.1019907929218137e-8, 4.3139832091694682e-9,},
{22.914636050333696, 3.2123508304962416e-1, 3.6633220173792710e-2, -5.9228324767696043e-3, -1.882379107379328e-4, 3.2274552870236244e-5, 4.9052463646336507e-7, -5.9064298731578425e-8, -2.0485712675098837e-8, -6.2163304813908160e-10,},
};
static const double owen_psia_coef[5][10] = {
{-218.57864954903122, 51.752257487741612, 1.3304715765661958e-1, 9.2048123521890745e-2, -6.0877528127241278e-3, -7.0013893644531700e-5, -4.9217728385458495e-5, -1.8578234189053723e-6, 7.4396426162029877e-7, -5.9157528981843864e-9,},
{-111.94350527506128, 55.175558131675861, 4.7366115762797613e-1, -4.7701750975398538e-2, -9.2445765329325809e-3, 7.0962838707454917e-4, 1.5140455277814658e-4, -7.7813159018954928e-7, -2.4729402281953378e-6, -1.0898887008726418e-7,},
{-2.041452011529441e-1, 55.969995858494106, -1.9295093699770936e-1, -5.6819574830421158e-3, 1.1073687302518981e-2, -9.0868489896815619e-5, -1.1999773777895820e-4, 9.9748697306154409e-6, 5.7911493603430550e-7, -2.3647526839778175e-7,},
{111.61366860604471, 56.404525305162447, 4.4403302410703782e-1, 7.1490030578883907e-2, -4.9184559079790816e-3, -1.3912698949042046e-3, -6.8490613661884005e-5, 1.2394328562905297e-6, 1.7719847841480384e-6, 2.4889095220628068e-7,},
{228.40683531269390, 60.056143904919826, 2.9583200718478960e-2, -1.5710838319490748e-1, -7.0017356811600801e-3, 3.3009615142224537e-3, 2.0318123852537664e-4, -6.5840216067828310e-5, -5.9077673352976155e-6, 1.3983942185303064e-6,},
};
static const double owen_oma_coef[5][10] = {
{25.541291140949806, 2.377889511272162e-1, -3.7337334723142133e-1, 2.4579295485161534e-2, 4.3840999514263623e-3, -3.1126873333599556e-4, -9.8443045771748915e-6, -7.9403103080496923e-7, 1.0840116743893556e-9, 9.2865105216887919e-9,},
{24.429357654237926, -9.5205745947740161e-1, 8.6738296270534816e-2, 3.0061543426062955e-2, -4.1532480523019988e-3, -3.7920928393860939e-4, 3.5117012399609737e-5, 4.6811877283079217e-6, -8.1836046585546861e-8, -6.1803706664211173e-8,},
{23.450465062489337, -9.7259278279739817e-2, 1.1082286925130981e-2, -3.1469883339372219e-2, -1.0041906996819648e-4, 5.6455168475133958e-4, -8.4403910211030209e-6, -3.8269157371098435e-6, 3.1422585261198437e-7, 9.3481729116773404e-9,},
{22.581778052947806, -8.7069701538602037e-1, -9.8140710050197307e-2, 2.6025931340678079e-2, 4.8165322168786755e-3, -1.906558772193363e-4, -4.6838759635421777e-5, -1.6608525315998471e-6, -3.2347811293516124e-8, 2.8104728109642000e-9,},
{21.518861835737142, 2.0494789509441385e-1, 3.5193604846503161e-1, 1.5305977982348925e-2, -7.5015367726336455e-3, -4.0322553186065610e-4, 1.0655320434844041e-4, 7.1792339586935752e-6, -1.603874697543020e-6, -1.613563462813512e-7,},
};
static const double owen_chia_coef[5][10] = {
{8.2378850337329404e-1, -3.7443109739678667, 4.0143936898854026e-1, 8.1822830214590811e-2, -8.5978790792656293e-3, -2.8350488448426132e-5, -4.2474671728156727e-5, -1.6214840884656678e-6, 7.8560442001953050e-7, -1.032016641696707e-8,},
{-2.1726062070318606, 7.8470515033132925e-1, 4.4044931004195718e-1, -8.0671247169971653e-2, -8.9672662444325007e-3, 9.2248978383109719e-4, 1.5143472266372874e-4, -1.6387009056475679e-6, -2.4405558979328144e-6, -1.0148113464009015e-7,},
{-4.8518673570735556e-1, 1.0016737299946743e-1, -4.7074888613099918e-1, -5.8604054305076092e-3, 1.4300208240553435e-2, -6.7127991650300028e-5, -1.3703764889645475e-4, 9.0505213684444634e-6, 6.0368690647808607e-7, -2.2135404747652171e-7,},
{-2.0950740076326087, -9.4447359463206877e-1, 4.0940512860493755e-1, 1.0261699700263508e-1, -5.3133241571955160e-3, -1.6634631550720911e-3, -5.9477519536647907e-5, 2.9651387319208926e-6, 1.6434499452070584e-6, 2.3720647656961084e-7,},
{6.3315163285678715e-1, 3.5241082918420464, 2.1223076605364606e-1, -1.5648122502767368e-1, -9.1964075390801980e-3, 3.3896161239812411e-3, 2.1485178626085787e-4, -6.6261759864793735e-5, -5.9257969712852667e-6, 1.3918759086160525e-6,},
};
static void get_owen_t0_icof(double tjd, double *t0, int *icof)
{
int i, j = 0;
double t0s[5] = {-3392455.5, -470455.5, 2451544.5, 5373544.5, 8295544.5, };
*t0 = t0s[0];
for (i = 1; i < 5; i++) {
if (tjd < (t0s[i-1] + t0s[i]) / 2) {
;
} else {
*t0 = t0s[i];
j++;
}
}
*icof = j;
}
/* precession matrix Owen 1990 */
static void owen_pre_matrix(double tjd, double *rp, int iflag)
{
int i, icof = 0;
double eps0 = 0, chia = 0, psia = 0, oma = 0;
double coseps0, sineps0, coschia, sinchia, cospsia, sinpsia, cosoma, sinoma;
double k[10], tau[10];
double t0;
get_owen_t0_icof(tjd, &t0, &icof);
// fprintf(stderr, "%d, %.17f\n", icof, t0);
tau[0] = 0;
tau[1] = (tjd - t0) / 36525.0 / 40.0;
for (i = 2; i <= 9; i++) {
tau[i] = tau[1] * tau[i-1];
}
k[0] = 1;
k[1] = tau[1];
k[2] = 2 * tau[2] - 1;
k[3] = 4 * tau[3] - 3 * tau[1];
k[4] = 8 * tau[4] - 8 * tau[2] + 1;
k[5] = 16 * tau[5] - 20 * tau[3] + 5 * tau[1];
k[6] = 32 * tau[6] - 48 * tau[4] + 18 * tau[2] - 1;
k[7] = 64 * tau[7] - 112 * tau[5] + 56 * tau[3] - 7 * tau[1];
k[8] = 128 * tau[8] - 256 * tau[6] + 160 * tau[4] - 32 * tau[2] + 1;
k[9] = 256 * tau[9] - 576 * tau[7] + 432 * tau[5] - 120 * tau[3] + 9 * tau[1];
for (i = 0; i < 10; i++) {
//eps += (k[i] * owen_eps0_coef[icof][i]);
psia += (k[i] * owen_psia_coef[icof][i]);
oma += (k[i] * owen_oma_coef[icof][i]);
chia += (k[i] * owen_chia_coef[icof][i]);
}
if (iflag & (SEFLG_JPLHOR | SEFLG_JPLHOR_APPROX)) {
/*
* In comparison with JPL Horizons we have an almost constant offset
* almost constant offset in ecl. longitude of about -0.000019 deg.
* We fix this as follows: */
psia += -0.000018560;
}
eps0 = 84381.448 / 3600.0;
//fprintf(stderr, "e=%.17f, ps=%.17f, om=%.17f, ch=%.17f\n", eps0, psia, oma, chia);
eps0 *= DEGTORAD;
psia *= DEGTORAD;
chia *= DEGTORAD;
oma *= DEGTORAD;
coseps0 = cos(eps0);
sineps0 = sin(eps0);
coschia = cos(chia);
sinchia = sin(chia);
cospsia = cos(psia);
sinpsia = sin(psia);
cosoma = cos(oma);
sinoma = sin(oma);
rp[0] = coschia * cospsia + sinchia * cosoma * sinpsia;
rp[1] = (-coschia * sinpsia + sinchia * cosoma * cospsia) * coseps0 + sinchia * sinoma * sineps0;
rp[2] = (-coschia * sinpsia + sinchia * cosoma * cospsia) * sineps0 - sinchia * sinoma * coseps0;
rp[3] = -sinchia * cospsia + coschia * cosoma * sinpsia;
rp[4] = (sinchia * sinpsia + coschia * cosoma * cospsia) * coseps0 + coschia * sinoma * sineps0;
rp[5] = (sinchia * sinpsia + coschia * cosoma * cospsia) * sineps0 - coschia * sinoma * coseps0;
rp[6] = sinoma * sinpsia;
rp[7] = sinoma * cospsia * coseps0 - cosoma * sineps0;
rp[8] = sinoma * cospsia * sineps0 + cosoma * coseps0;
/*for (i = 0; i < 3; i++) {
fprintf(stderr, "(%.17f %.17f %.17f)\n", rp[i*3], rp[i*3+1],rp[i*3+2]);
} */
}
static void epsiln_owen_1986(double tjd, double *eps)
{
int i, icof = 0;
double k[10], tau[10];
double t0;
get_owen_t0_icof(tjd, &t0, &icof);
*eps = 0;
tau[0] = 0;
tau[1] = (tjd - t0) / 36525.0 / 40.0;
for (i = 2; i <= 9; i++) {
tau[i] = tau[1] * tau[i-1];
}
k[0] = 1;
k[1] = tau[1];
k[2] = 2 * tau[2] - 1;
k[3] = 4 * tau[3] - 3 * tau[1];
k[4] = 8 * tau[4] - 8 * tau[2] + 1;
k[5] = 16 * tau[5] - 20 * tau[3] + 5 * tau[1];
k[6] = 32 * tau[6] - 48 * tau[4] + 18 * tau[2] - 1;
k[7] = 64 * tau[7] - 112 * tau[5] + 56 * tau[3] - 7 * tau[1];
k[8] = 128 * tau[8] - 256 * tau[6] + 160 * tau[4] - 32 * tau[2] + 1;
k[9] = 256 * tau[9] - 576 * tau[7] + 432 * tau[5] - 120 * tau[3] + 9 * tau[1];
for (i = 0; i < 10; i++) {
*eps += (k[i] * owen_eps0_coef[icof][i]);
}
//fprintf(stderr, "eps=%.17f\n", *eps);
}
/* Obliquity of the ecliptic at Julian date J
*
* IAU Coefficients are from:
* J. H. Lieske, T. Lederle, W. Fricke, and B. Morando,
* "Expressions for the Precession Quantities Based upon the IAU
* (1976) System of Astronomical Constants," Astronomy and Astrophysics
* 58, 1-16 (1977).
*
* Before or after 200 years from J2000, the formula used is from:
* J. Laskar, "Secular terms of classical planetary theories
* using the results of general theory," Astronomy and Astrophysics
* 157, 59070 (1986).
*
* Bretagnon, P. et al.: 2003, "Expressions for Precession Consistent with
* the IAU 2000A Model". A&A 400,785
*B03 84381.4088 -46.836051*t -1667*10-7*t2 +199911*10-8*t3 -523*10-9*t4 -248*10-10*t5 -3*10-11*t6
*C03 84381.406 -46.836769*t -1831*10-7*t2 +20034*10-7*t3 -576*10-9*t4 -434*10-10*t5
*
* See precess and page B18 of the Astronomical Almanac.
*/
#define OFFSET_EPS_JPLHORIZONS (35.95)
#define DCOR_EPS_JPL_TJD0 2437846.5
#define NDCOR_EPS_JPL 51
double dcor_eps_jpl[] = {
36.726, 36.627, 36.595, 36.578, 36.640, 36.659, 36.731, 36.765,
36.662, 36.555, 36.335, 36.321, 36.354, 36.227, 36.289, 36.348, 36.257, 36.163,
35.979, 35.896, 35.842, 35.825, 35.912, 35.950, 36.093, 36.191, 36.009, 35.943,
35.875, 35.771, 35.788, 35.753, 35.822, 35.866, 35.771, 35.732, 35.543, 35.498,
35.449, 35.409, 35.497, 35.556, 35.672, 35.760, 35.596, 35.565, 35.510, 35.394,
35.385, 35.375, 35.415,
};
double swi_epsiln(double J, int32 iflag)
{
double T, eps;
double tofs, dofs, t0, t1;
int prec_model = swed.astro_models[SE_MODEL_PREC_LONGTERM];
int prec_model_short = swed.astro_models[SE_MODEL_PREC_SHORTTERM];
int jplhora_model = swed.astro_models[SE_MODEL_JPLHORA_MODE];
AS_BOOL is_jplhor = FALSE;
if (prec_model == 0) prec_model = SEMOD_PREC_DEFAULT;
if (prec_model_short == 0) prec_model_short = SEMOD_PREC_DEFAULT_SHORT;
if (jplhora_model == 0) jplhora_model = SEMOD_JPLHORA_DEFAULT;
if (iflag & SEFLG_JPLHOR)
is_jplhor = TRUE;
if ((iflag & SEFLG_JPLHOR_APPROX)
&& jplhora_model == SEMOD_JPLHORA_3
&& J <= HORIZONS_TJD0_DPSI_DEPS_IAU1980)
is_jplhor = TRUE;
T = (J - 2451545.0)/36525.0;
if (is_jplhor) {
if (J > 2378131.5 && J < 2525323.5) { // between 1.1.1799 and 1.1.2202
eps = (((1.813e-3*T-5.9e-4)*T-46.8150)*T+84381.448)*DEGTORAD/3600;
} else {
epsiln_owen_1986(J, &eps);
eps *= DEGTORAD;
}
} else if ((iflag & SEFLG_JPLHOR_APPROX) && jplhora_model == SEMOD_JPLHORA_2) {
eps = (((1.813e-3*T-5.9e-4)*T-46.8150)*T+84381.448)*DEGTORAD/3600;
} else if (prec_model_short == SEMOD_PREC_IAU_1976 && fabs(T) <= PREC_IAU_1976_CTIES ) {
eps = (((1.813e-3*T-5.9e-4)*T-46.8150)*T+84381.448)*DEGTORAD/3600;
} else if (prec_model == SEMOD_PREC_IAU_1976) {
eps = (((1.813e-3*T-5.9e-4)*T-46.8150)*T+84381.448)*DEGTORAD/3600;
} else if (prec_model_short == SEMOD_PREC_IAU_2000 && fabs(T) <= PREC_IAU_2000_CTIES ) {
eps = (((1.813e-3*T-5.9e-4)*T-46.84024)*T+84381.406)*DEGTORAD/3600;
} else if (prec_model == SEMOD_PREC_IAU_2000) {
eps = (((1.813e-3*T-5.9e-4)*T-46.84024)*T+84381.406)*DEGTORAD/3600;
} else if (prec_model_short == SEMOD_PREC_IAU_2006 && fabs(T) <= PREC_IAU_2006_CTIES) {
eps = (((((-4.34e-8 * T -5.76e-7) * T +2.0034e-3) * T -1.831e-4) * T -46.836769) * T + 84381.406) * DEGTORAD / 3600.0;
} else if (prec_model == SEMOD_PREC_NEWCOMB) {
double Tn = (J - 2396758.0)/36525.0;
eps = (0.0017 * Tn * Tn * Tn - 0.0085 * Tn * Tn - 46.837 * Tn + 84451.68) * DEGTORAD / 3600.0;
} else if (prec_model == SEMOD_PREC_IAU_2006) {
eps = (((((-4.34e-8 * T -5.76e-7) * T +2.0034e-3) * T -1.831e-4) * T -46.836769) * T + 84381.406) * DEGTORAD / 3600.0;
} else if (prec_model == SEMOD_PREC_BRETAGNON_2003) {
eps = ((((((-3e-11 * T - 2.48e-8) * T -5.23e-7) * T +1.99911e-3) * T -1.667e-4) * T -46.836051) * T + 84381.40880) * DEGTORAD / 3600.0;/* */
} else if (prec_model == SEMOD_PREC_SIMON_1994) {
eps = (((((2.5e-8 * T -5.1e-7) * T +1.9989e-3) * T -1.52e-4) * T -46.80927) * T + 84381.412) * DEGTORAD / 3600.0;/* */
} else if (prec_model == SEMOD_PREC_WILLIAMS_1994) {
eps = ((((-1.0e-6 * T +2.0e-3) * T -1.74e-4) * T -46.833960) * T + 84381.409) * DEGTORAD / 3600.0;/* */
} else if (prec_model == SEMOD_PREC_LASKAR_1986 || prec_model == SEMOD_PREC_WILL_EPS_LASK) {
T /= 10.0;
eps = ((((((((( 2.45e-10*T + 5.79e-9)*T + 2.787e-7)*T
+ 7.12e-7)*T - 3.905e-5)*T - 2.4967e-3)*T
- 5.138e-3)*T + 1.99925)*T - 0.0155)*T - 468.093)*T
+ 84381.448;
eps *= DEGTORAD/3600.0;
} else if (prec_model == SEMOD_PREC_OWEN_1990) {
epsiln_owen_1986(J, &eps);
eps *= DEGTORAD;
//fprintf(stderr, "epso=%.17f\n", eps);
} else { /* SEMOD_PREC_VONDRAK_2011 */
swi_ldp_peps(J, NULL, &eps);
if ((iflag & SEFLG_JPLHOR_APPROX) && jplhora_model != SEMOD_JPLHORA_2) {
tofs = (J - DCOR_EPS_JPL_TJD0) / 365.25;
dofs = OFFSET_EPS_JPLHORIZONS;
if (tofs < 0) {
tofs = 0;
dofs = dcor_eps_jpl[0];
} else if (tofs >= NDCOR_EPS_JPL - 1) {
tofs = NDCOR_EPS_JPL;
dofs = dcor_eps_jpl[NDCOR_EPS_JPL - 1];
} else {
t0 = (int) tofs;
t1 = t0 + 1;
dofs = dcor_eps_jpl[(int)t0];
dofs = (tofs - t0) * (dcor_eps_jpl[(int)t0] - dcor_eps_jpl[(int)t1]) + dcor_eps_jpl[(int)t0];
}
dofs /= (1000.0 * 3600.0);
eps += dofs * DEGTORAD;
}
//fprintf(stderr, "epsv=%.17f\n", eps);
}
return(eps);
}
/* Precession of the equinox and ecliptic
* from epoch Julian date J to or from J2000.0
*
* Original program by Steve Moshier.
* Changes in program structure and implementation of IAU 2003 (P03) and
* Vondrak 2011 by Dieter Koch.
*
* SEMOD_PREC_VONDRAK_2011
* J. Vondrák, N. Capitaine, and P. Wallace, "New precession expressions,
* valid for long time intervals", A&A 534, A22 (2011)
*
* SEMOD_PREC_IAU_2006
* N. Capitaine, P.T. Wallace, and J. Chapront, "Expressions for IAU 2000
* precession quantities", 2003, A&A 412, 567-586 (2003).
* This is a "short" term model, that can be combined with other models
*
* SEMOD_PREC_WILLIAMS_1994
* James G. Williams, "Contributions to the Earth's obliquity rate,
* precession, and nutation," Astron. J. 108, 711-724 (1994).
*
* SEMOD_PREC_SIMON_1994
* J. L. Simon, P. Bretagnon, J. Chapront, M. Chapront-Touze', G. Francou,
* and J. Laskar, "Numerical Expressions for precession formulae and
* mean elements for the Moon and the planets," Astronomy and Astrophysics
* 282, 663-683 (1994).
*
* SEMOD_PREC_IAU_1976
* IAU Coefficients are from:
* J. H. Lieske, T. Lederle, W. Fricke, and B. Morando,
* "Expressions for the Precession Quantities Based upon the IAU