File Coverage

lib/Astro/Montenbruck/Ephemeris/Planet/Saturn.pm
Criterion Covered Total %
statement 135 135 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 2 2 100.0
total 148 148 100.0


line stmt bran cond sub pod time code
1             package Astro::Montenbruck::Ephemeris::Planet::Saturn;
2              
3 2     2   1284 use strict;
  2         6  
  2         66  
4 2     2   12 use warnings;
  2         4  
  2         67  
5 2     2   11 use Math::Trig qw/:pi/;
  2         5  
  2         272  
6 2     2   16 use base qw/Astro::Montenbruck::Ephemeris::Planet/;
  2         4  
  2         203  
7 2     2   16 use Astro::Montenbruck::Ephemeris::Pert qw/pert/;
  2         4  
  2         104  
8 2     2   22 use Astro::Montenbruck::MathUtils qw/frac ARCS/;
  2         6  
  2         106  
9 2     2   12 use Astro::Montenbruck::Ephemeris::Planet qw/$SA/;
  2         4  
  2         2735  
10              
11             our $VERSION = 0.01;
12              
13             sub new {
14 5     5 1 11 my $class = shift;
15 5         27 $class->SUPER::new( id => $SA );
16             }
17              
18             sub heliocentric {
19 5     5 1 12 my ( $self, $t ) = @_;
20              
21             # Mean anomalies of planets in [rad]
22 5         23 my $m5 = pi2 * frac( 0.0565314 + 8.4302963 * $t );
23 5         19 my $m6 = pi2 * frac( 0.8829867 + 3.3947688 * $t );
24 5         14 my $m7 = pi2 * frac( 0.3969537 + 1.1902586 * $t );
25 5         16 my $m8 = pi2 * frac( 0.7208473 + 0.6068623 * $t );
26              
27 5         15 my ( $dl, $dr, $db ) = ( 0, 0, 0 ); # Corrections in longitude ["],
28 5     355   21 my $pert_cb = sub { $dl += $_[0]; $dr += $_[1]; $db += $_[2] };
  355         546  
  355         484  
  355         573  
29              
30             # Perturbations by Saturn
31 5         23 my $term = pert(
32             T => $t,
33             M => $m6,
34             m => $m5,
35             I_min => 0,
36             I_max => 11,
37             i_min => -6,
38             i_max => 0,
39             callback => $pert_cb
40             );
41 5         23 $term->( 0, -1, 0, 12.0, -1.4, -13.9, 6.4, 1.2, -1.8 );
42 5         18 $term->( 0, -2, 0, 0.0, -0.2, -0.9, 1.0, 0.0, -0.1 );
43 5         17 $term->( 1, 1, 0, 0.9, 0.4, -1.8, 1.9, 0.2, 0.2 );
44 5         22 $term->( 1, 0, 0, -348.3, 22907.7, -52915.5, -752.2, -3266.5, 8314.4 );
45 5         16 $term->( 1, 0, 1, -225.2, -146.2, 337.7, -521.3, 79.6, 17.4 );
46 5         19 $term->( 1, 0, 2, 1.3, -1.4, 3.2, 2.9, 0.1, -0.4 );
47 5         18 $term->( 1, -1, 0, -1.0, -30.7, 108.6, -815.0, -3.6, -9.3 );
48 5         18 $term->( 1, -2, 0, -2.0, -2.7, -2.1, -11.9, -0.1, -0.4 );
49 5         18 $term->( 2, 1, 0, 0.1, 0.2, -1.0, 0.3, 0.0, 0.0 );
50 5         15 $term->( 2, 0, 0, 44.2, 724.0, -1464.3, -34.7, -188.7, 459.1 );
51 5         21 $term->( 2, 0, 1, -17.0, -11.3, 18.9, -28.6, 1.0, -3.7 );
52 5         19 $term->( 2, -1, 0, -3.5, -426.6, -546.5, -26.5, -1.6, -2.7 );
53 5         23 $term->( 2, -1, 1, 3.5, -2.2, -2.6, -4.3, 0.0, 0.0 );
54 5         23 $term->( 2, -2, 0, 10.5, -30.9, -130.5, -52.3, -1.9, 0.2 );
55 5         23 $term->( 2, -3, 0, -0.2, -0.4, -1.2, -0.1, -0.1, 0.0 );
56 5         22 $term->( 3, 0, 0, 6.5, 30.5, -61.1, 0.4, -11.6, 28.1 );
57 5         21 $term->( 3, 0, 1, -1.2, -0.7, 1.1, -1.8, -0.2, -0.6 );
58 5         22 $term->( 3, -1, 0, 29.0, -40.2, 98.2, 45.3, 3.2, -9.4 );
59 5         20 $term->( 3, -1, 1, 0.6, 0.6, -1.0, 1.3, 0.0, 0.0 );
60 5         21 $term->( 3, -2, 0, -27.0, -21.1, -68.5, 8.1, -19.8, 5.4 );
61 5         18 $term->( 3, -2, 1, 0.9, -0.5, -0.4, -2.0, -0.1, -0.8 );
62 5         18 $term->( 3, -3, 0, -5.4, -4.1, -19.1, 26.2, -0.1, -0.1 );
63 5         17 $term->( 4, 0, 0, 0.6, 1.4, -3.0, -0.2, -0.6, 1.6 );
64 5         19 $term->( 4, -1, 0, 1.5, -2.5, 12.4, 4.7, 1.0, -1.1 );
65 5         23 $term->( 4, -2, 0, -821.9, -9.6, -26.0, 1873.6, -70.5, -4.4 );
66 5         21 $term->( 4, -2, 1, 4.1, -21.9, -50.3, -9.9, 0.7, -3.0 );
67 5         17 $term->( 4, -3, 0, -2.0, -4.7, -19.3, 8.2, -0.1, -0.3 );
68 5         19 $term->( 4, -4, 0, -1.5, 1.3, 6.5, 7.3, 0.0, 0.0 );
69 5         17 $term->( 5, -2, 0, -2627.6, -1277.3, 117.4, -344.1, -13.8, -4.3 );
70 5         20 $term->( 5, -2, 1, 63.0, -98.6, 12.7, 6.7, 0.1, -0.2 );
71 5         15 $term->( 5, -2, 2, 1.7, 1.2, -0.2, 0.3, 0.0, 0.0 );
72 5         17 $term->( 5, -3, 0, 0.4, -3.6, -11.3, -1.6, 0.0, -0.3 );
73 5         18 $term->( 5, -4, 0, -1.4, 0.3, 1.5, 6.3, -0.1, 0.0 );
74 5         18 $term->( 5, -5, 0, 0.3, 0.6, 3.0, -1.7, 0.0, 0.0 );
75 5         15 $term->( 6, -2, 0, -146.7, -73.7, 166.4, -334.3, -43.6, -46.7 );
76 5         19 $term->( 6, -2, 1, 5.2, -6.8, 15.1, 11.4, 1.7, -1.0 );
77 5         15 $term->( 6, -3, 0, 1.5, -2.9, -2.2, -1.3, 0.1, -0.1 );
78 5         24 $term->( 6, -4, 0, -0.7, -0.2, -0.7, 2.8, 0.0, 0.0 );
79 5         35 $term->( 6, -5, 0, 0.0, 0.5, 2.5, -0.1, 0.0, 0.0 );
80 5         20 $term->( 6, -6, 0, 0.3, -0.1, -0.3, -1.2, 0.0, 0.0 );
81 5         24 $term->( 7, -2, 0, -9.6, -3.9, 9.6, -18.6, -4.7, -5.3 );
82 5         30 $term->( 7, -2, 1, 0.4, -0.5, 1.0, 0.9, 0.3, -0.1 );
83 5         22 $term->( 7, -3, 0, 3.0, 5.3, 7.5, -3.5, 0.0, 0.0 );
84 5         27 $term->( 7, -4, 0, 0.2, 0.4, 1.6, -1.3, 0.0, 0.0 );
85 5         21 $term->( 7, -5, 0, -0.1, 0.2, 1.0, 0.5, 0.0, 0.0 );
86 5         22 $term->( 7, -6, 0, 0.2, 0.0, 0.2, -1.0, 0.0, 0.0 );
87 5         17 $term->( 8, -2, 0, -0.7, -0.2, 0.6, -1.2, -0.4, -0.4 );
88 5         18 $term->( 8, -3, 0, 0.5, 1.0, -2.0, 1.5, 0.1, 0.2 );
89 5         16 $term->( 8, -4, 0, 0.4, 1.3, 3.6, -0.9, 0.0, -0.1 );
90 5         17 $term->( 9, -4, 0, 4.0, -8.7, -19.9, -9.9, 0.2, -0.4 );
91 5         17 $term->( 9, -4, 1, 0.5, 0.3, 0.8, -1.8, 0.0, 0.0 );
92 5         17 $term->( 10, -4, 0, 21.3, -16.8, 3.3, 3.3, 0.2, -0.2 );
93 5         16 $term->( 10, -4, 1, 1.0, 1.7, -0.4, 0.4, 0.0, 0.0 );
94 5         17 $term->( 11, -4, 0, 1.6, -1.3, 3.0, 3.7, 0.8, -0.2 );
95              
96             # Perturbations by Uranus
97 5         15 $term = pert(
98             T => $t,
99             M => $m6,
100             m => $m7,
101             I_min => 0,
102             I_max => 3,
103             i_min => -5,
104             i_max => -1,
105             callback => $pert_cb
106             );
107 5         25 $term->( 0, -1, 0, 1.0, 0.7, 0.4, -1.5, 0.1, 0.0 );
108 5         37 $term->( 0, -2, 0, 0.0, -0.4, -1.1, 0.1, -0.1, -0.1 );
109 5         27 $term->( 0, -3, 0, -0.9, -1.2, -2.7, 2.1, -0.5, -0.3 );
110 5         22 $term->( 1, -1, 0, 7.8, -1.5, 2.3, 12.7, 0.0, 0.0 );
111 5         22 $term->( 1, -2, 0, -1.1, -8.1, 5.2, -0.3, -0.3, -0.3 );
112 5         19 $term->( 1, -3, 0, -16.4, -21.0, -2.1, 0.0, 0.4, 0.0 );
113 5         19 $term->( 2, -1, 0, 0.6, -0.1, 0.1, 1.2, 0.1, 0.0 );
114 5         17 $term->( 2, -2, 0, -4.9, -11.7, 31.5, -13.3, 0.0, -0.2 );
115 5         19 $term->( 2, -3, 0, 19.1, 10.0, -22.1, 42.1, 0.1, -1.1 );
116 5         15 $term->( 2, -4, 0, 0.9, -0.1, 0.1, 1.4, 0.0, 0.0 );
117 5         18 $term->( 3, -2, 0, -0.4, -0.9, 1.7, -0.8, 0.0, -0.3 );
118 5         16 $term->( 3, -3, 0, 2.3, 0.0, 1.0, 5.7, 0.3, 0.3 );
119 5         19 $term->( 3, -4, 0, 0.3, -0.7, 2.0, 0.7, 0.0, 0.0 );
120 5         17 $term->( 3, -5, 0, -0.1, -0.4, 1.1, -0.3, 0.0, 0.0 );
121              
122             # Perturbations by Neptune
123 5         20 $term = pert(
124             T => $t,
125             M => $m6,
126             m => $m8,
127             I_min => 1,
128             I_max => 2,
129             i_min => -2,
130             i_max => -1,
131             callback => $pert_cb
132             );
133              
134 5         32 $term->( 1, -1, 0, -1.3, -1.2, 2.3, -2.5, 0.0, 0.0 );
135 5         25 $term->( 1, -2, 0, 1.0, -0.1, 0.1, 1.4, 0.0, 0.0 );
136 5         23 $term->( 2, -2, 0, 1.1, -0.1, 0.2, 3.3, 0.0, 0.0 );
137              
138             # Perturbations by Saturn and Uranus
139 5         25 my $phi = ( -2 * $m5 + 5 * $m6 - 3 * $m7 );
140 5         13 my $c = cos($phi);
141 5         9 my $s = sin($phi);
142              
143 5         11 $dl += -0.8 * $c - 0.1 * $s;
144 5         11 $dr += -0.2 * $c + 1.8 * $s;
145 5         9 $db += +0.3 * $c + 0.5 * $s;
146              
147 5         11 $phi = ( -2 * $m5 + 6 * $m6 - 3 * $m7 );
148 5         9 $c = cos($phi);
149 5         11 $s = sin($phi);
150 5         12 $dl += ( +2.4 - 0.7 * $t ) * $c + ( 27.8 - 0.4 * $t ) * $s;
151 5         16 $dr += +2.1 * $c - 0.2 * $s;
152              
153 5         13 $phi = ( -2 * $m5 + 7 * $m6 - 3 * $m7 );
154 5         10 $c = cos($phi);
155 5         8 $s = sin($phi);
156 5         9 $dl += +0.1 * $c + 1.6 * $s;
157 5         10 $dr += -3.6 * $c + 0.3 * $s;
158 5         7 $db += -0.2 * $c + 0.6 * $s;
159              
160             # Ecliptic coordinates ([rad],[AU])
161 5         24 my $l =
162             pi2 *
163             frac( 0.2561136 + $m6 / pi2 +
164             ( ( 5018.6 + $t * 1.9 ) * $t + $dl ) / 1296.0e3 );
165 5         11 my $r = 9.557584 - 0.000186 * $t + $dr * 1.0e-5;
166 5         13 my $b = ( 175.1 - 10.2 * $t + $db ) / ARCS;
167              
168 5         58 $l, $b, $r;
169              
170             }
171              
172             # Intermediate variables for calculating geocentric positions.
173             sub _lbr_geo {
174 5     5   18 my ( $self, $t ) = @_;
175              
176 5         21 my $m = pi2 * frac( 0.8829867 + 3.3947688 * $t );
177 5         14 my $cm = cos($m);
178 5         11 my $dl = 5.84 + 0.65 * $cm;
179 5         9 my $dr = 3.09 * sin($m);
180 5         10 my $db = 0.24 * $cm;
181              
182 5         15 $dl, $db, $dr;
183             }
184              
185             1;
186              
187             __END__
188              
189             =pod
190              
191             =encoding UTF-8
192              
193             =head1 NAME
194              
195             Astro::Montenbruck::Ephemeris::Planet::Saturn - Saturn.
196              
197             =head1 SYNOPSIS
198              
199             use Astro::Montenbruck::Ephemeris::Planet::Saturn;
200             my $planet = Astro::Montenbruck::Ephemeris::Planet::Saturn->new();
201             my @geo = $planet->position($t); # apparent geocentric ecliptical coordinates
202              
203             =head1 DESCRIPTION
204              
205             Child class of L<Astro::Montenbruck::Ephemeris::Planet>, responsible for calculating
206             B<Saturn> position.
207              
208             =head1 METHODS
209              
210             =head2 Astro::Montenbruck::Ephemeris::Planet::Saturn->new
211              
212             Constructor.
213              
214             =head2 $self->heliocentric($t)
215              
216             See description in L<Astro::Montenbruck::Ephemeris::Planet>.
217              
218             =head1 AUTHOR
219              
220             Sergey Krushinsky, C<< <krushi at cpan.org> >>
221              
222             =head1 COPYRIGHT AND LICENSE
223              
224             Copyright (C) 2009-2019 by Sergey Krushinsky
225              
226             This library is free software; you can redistribute it and/or modify
227             it under the same terms as Perl itself.
228              
229             =cut