-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNutation.pm
226 lines (175 loc) · 7 KB
/
Nutation.pm
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
package AstroScript::Nutation;
use warnings;
use strict;
use Data::Dumper;
our $VERSION = '1.00';
use Exporter qw/import/;
use Readonly;
our %EXPORT_TAGS = (
all => [ qw/nut_lon nut_obl ecl_obl/ ],
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
use AstroScript::MathUtils qw/ddd reduce_rad polynome/;
use Math::Trig qw/deg2rad/;
#
# Constant terms.
#
Readonly::Array our @TABLE => (
[ 0, 0, 0, 0, 1, -171996, -1742, 92025, 89 ],
[-2, 0, 0, 2, 2, -13187, -16, 5736, -31 ],
[ 0, 0, 0, 2, 2, -2274, -2, 977, -5 ],
[ 0, 0, 0, 0, 2, 2062, 2, -895, 5 ],
[ 0, 1, 0, 0, 0, 1426, -34, 54, -1 ],
[ 0, 0, 1, 0, 0, 712, 1, -7, 0 ],
[-2, 1, 0, 2, 2, -517, 12, 224, -6 ],
[ 0, 0, 0, 2, 1, -386, -4, 200, 0 ],
[ 0, 0, 1, 2, 2, -301, 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],
[-2, 0, 2, 2, 2, 6, 0, -3, 0 ],
[-2, 0, 1, 2, 1, 6, 0, -3, 0 ],
[ 2, 0, -2, 0, 1, -6, 0, 3, 0 ],
[ 2, 0, 0, 0, 1, -6, 0, 3, 0 ],
[ 0, -1, 1, 0, 0, 5, 0, 0, 0 ],
[-2, -1, 0, 2, 1, -5, 0, 3, 0 ],
[-2, 0, 0, 0, 1, -5, 0, 3, 0 ],
[ 0, 0, 2, 2, 1, -5, 0, 3, 0 ],
[-2, 0, 2, 0, 1, 4, 0, 0, 0 ],
[-2, 1, 0, 2, 1, 4, 0, 0, 0 ],
[ 0, 0, 1, -2, 0, 4, 0, 0, 0 ],
[-1, 0, 1, 0, 0, -4, 0, 0, 0 ],
[-2, 1, 0, 0, 0, -4, 0, 0, 0 ],
[ 1, 0, 0, 0, 0, -4, 0, 0, 0 ],
[ 0, 0, 1, 2, 0, 3, 0, 0, 0 ],
[ 0, 0, -2, 2, 2, -3, 0, 0, 0 ],
[-1, -1, 1, 0, 0, -3, 0, 0, 0 ],
[ 0, 1, 1, 0, 0, -3, 0, 0, 0 ],
[ 0, -1, 1, 2, 2, -3, 0, 0, 0 ],
[ 2, -1, -1, 2, 2, -3, 0, 0, 0 ],
[ 0, 0, 3, 2, 2, -3, 0, 0, 0 ],
[ 2, -1, 0, 2, 2, -3, 0, 0, 0 ]
);
Readonly::Array our @KD
=> map { deg2rad $_ , 1} (297.85036, 445267.111480, -0.0019142, 1.0/189474);
Readonly::Array our @KM
=> map { deg2rad $_, 1 } (357.52772, 35999.050340, -0.0001603, -1.0/300000);
Readonly::Array our @KM1
=> map { deg2rad $_, 1 } (134.96298, 477198.867398, 0.0086972, 1.0/ 56250);
Readonly::Array our @KF
=> map { deg2rad $_, 1 } (93.27191, 483202.017538, -0.0036825, 1.0/327270);
Readonly::Array our @KO
=> map { deg2rad $_, 1 } (125.04452, -1934.136261, 0.0020708, 1.0/450000);
# Terms for calculating ecliptic obliquity in radians
Readonly::Array our @ETERMS
=> map { deg2rad(ddd(@$_)) }
([23, 26, 21.448], [0, 0, -4680.93], [0, 0, -1.55], [0, 0, 1999.25],
[ 0, 0, -51.38 ], [0, 0, -249.67], [0, 0, -39.05], [0, 0, 7.12],
[ 0, 0, 27.87 ], [0, 0, 5.79], [0, 0, 2.45]);
sub _iter_table {
my ($t, $callback) = @_;
print Dumper([$t, \@KD, polynome($t, @KD)]);
my ($D, $M, $M1, $F, $omega)
= map { reduce_rad(polynome($t, @$_)) } (\@KD, \@KM, \@KM1, \@KF, \@KO);
# Astrolabe: 2.39044329248 1.65769978124 4.00166320529 2.50294014427 0.196403352891
for (my $i = 0; $i < @TABLE; $i++) {
my ($tD, $tM, $tM1, $tF, $tomega, $tpsiK, $tpsiT, $tepsK, $tepsT) = @{$TABLE[$i]};
my $arg = $D * $tD + $M * $tM + $M1 * $tM1 + $F * $tF + $omega * $tomega; # 0.19640335289105515
my $x = $tpsiK / 10000.0 + $tpsiT / 100000.0 * $t;
$callback->($x, $arg);
}
}
sub nut_lon {
my $t = shift;
my $delta_psi = 0;
_iter_table(
$t,
sub {
my ($x, $arg) = @_;
$delta_psi += $x * sin($arg);
}
);
$delta_psi /= 3600;
deg2rad( $delta_psi );
}
sub nut_obl {
my $t = shift;
my $delta_eps = 0;
_iter_table(
$t,
sub {
my ($x, $arg) = @_;
$delta_eps += $x * cos($arg);
}
);
$delta_eps /= 3600;
deg2rad( $delta_eps );
}
sub ecl_obl {
my $t = shift;
polynome($t / 100, @ETERMS)
}
1; # End of AstroScript::Nutation
__END__
=head1 NAME
AstroScript::Nutation - nutation and obliquity of ecliptic
=head1 VERSION
Version 0.01
=head1 SYNOPSIS
use AstroScript::Nutation qw/:all/;
$delta_psi = nut_lon($t); # nutation in longitude
$delta_eps = nut_obl($t); # nutation in ecliptic obliquity
$epsilon = ecl_obl($t); # obliquity of ecliptic
...
=head1 EXPORT
=over
=item * L</$delta_psi = nut_lon($t)>
=item * L</$delta_eps = nut_obl($t)>
=item * L</$epsilon = ecl_obl($t)>
=back
=head1 SUBROUTINES/METHODS
=head2 $delta_psi = nut_lon($t)
Nutation in longitude (radians)
=head2 $delta_eps = nut_obl($t)
Nutation in obliquity (radians)
=head2 $epsilon = ecl_obl($t)
Obliquity of ecliptic in radians. Accuracy is 0.01" between 1000 and 3000,
and a few arc-seconds after 10,000 years.
=head1 AUTHOR
Sergey Krushinsky, C<< <krushinsky at gmail.com> >>
=head1 LICENSE AND COPYRIGHT
Copyright 2010-2019 Sergey Krushinsky.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
=cut