File Coverage

lib/Astro/Montenbruck/Ephemeris/Planet/Mars.pm
Criterion Covered Total %
statement 159 159 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 2 2 100.0
total 172 172 100.0


line stmt bran cond sub pod time code
1             package Astro::Montenbruck::Ephemeris::Planet::Mars;
2              
3 1     1   471 use strict;
  1         2  
  1         26  
4 1     1   5 use warnings;
  1         1  
  1         25  
5              
6 1     1   5 use base qw/Astro::Montenbruck::Ephemeris::Planet/;
  1         2  
  1         60  
7              
8 1     1   5 use Math::Trig qw/:pi/;
  1         2  
  1         106  
9 1     1   7 use Astro::Montenbruck::Ephemeris::Pert qw /pert/;
  1         1  
  1         53  
10 1     1   6 use Astro::Montenbruck::MathUtils qw /frac ARCS/;
  1         8  
  1         44  
11 1     1   6 use Astro::Montenbruck::Ephemeris::Planet qw/$MA/;
  1         2  
  1         1390  
12              
13             our $VERSION = 0.01;
14              
15             sub new {
16 2     2 1 4 my $class = shift;
17 2         11 $class->SUPER::new( id => $MA );
18             }
19              
20             sub heliocentric {
21 2     2 1 5 my ( $self, $t ) = @_;
22              
23             # Mean anomalies of planets in [rad]
24 2         8 my $m2 = pi2 * frac( 0.1382208 + 162.5482542 * $t );
25 2         6 my $m3 = pi2 * frac( 0.9926208 + 99.9970236 * $t );
26 2         8 my $m4 = pi2 * frac( 0.0538553 + 53.1662736 * $t );
27 2         8 my $m5 = pi2 * frac( 0.0548944 + 8.4290611 * $t );
28 2         5 my $m6 = pi2 * frac( 0.8811167 + 3.3935250 * $t );
29              
30 2         6 my ( $dl, $dr, $db ) = ( 0, 0, 0 ); # Corrections in longitude ["],
31 2     212   9 my $pert_cb = sub { $dl += $_[0]; $dr += $_[1]; $db += $_[2] };
  212         270  
  212         277  
  212         372  
32              
33             # Perturbations by Venus
34 2         9 my $term = pert(
35             T => $t,
36             M => $m4,
37             m => $m2,
38             I_min => 0,
39             I_max => 7,
40             i_min => -2,
41             i_max => -1,
42             callback => $pert_cb
43             );
44              
45 2         11 $term->( 0, -1, 0, -0.01, -0.03, 0.10, -0.04, 0.00, 0.00 );
46 2         8 $term->( 1, -1, 0, 0.05, 0.10, -2.08, 0.75, 0.00, 0.00 );
47 2         8 $term->( 2, -1, 0, -0.25, -0.57, -2.58, 1.18, 0.05, -0.04 );
48 2         8 $term->( 2, -2, 0, 0.02, 0.02, 0.13, -0.14, 0.00, 0.00 );
49 2         6 $term->( 3, -1, 0, 3.41, 5.38, 1.87, -1.15, 0.01, -0.01 );
50 2         11 $term->( 3, -2, 0, 0.02, 0.02, 0.11, -0.13, 0.00, 0.00 );
51 2         9 $term->( 4, -1, 0, 0.32, 0.49, -1.88, 1.21, -0.07, 0.07 );
52 2         10 $term->( 4, -2, 0, 0.03, 0.03, 0.12, -0.14, 0.00, 0.00 );
53 2         7 $term->( 5, -1, 0, 0.04, 0.06, -0.17, 0.11, -0.01, 0.01 );
54 2         6 $term->( 5, -2, 0, 0.11, 0.09, 0.35, -0.43, -0.01, 0.01 );
55 2         6 $term->( 6, -2, 0, -0.36, -0.28, -0.20, 0.25, 0.00, 0.00 );
56 2         7 $term->( 7, -2, 0, -0.03, -0.03, 0.11, -0.13, 0.00, -0.01 );
57              
58             # Keplerian motion and perturbations by the Earth
59 2         6 $term = pert(
60             T => $t,
61             M => $m4,
62             m => $m3,
63             I_min => -1,
64             I_max => 16,
65             i_min => -9,
66             i_max => 0,
67             callback => $pert_cb
68             );
69              
70 2         35 $term->( 1, 0, 0, -5.32, 38481.97, -141856.04, 0.40, -6321.67, 1876.89 );
71 2         9 $term->( 1, 0, 1, -1.12, 37.98, -138.67, -2.93, 37.28, 117.48 );
72 2         7 $term->( 1, 0, 2, -0.32, -0.03, 0.12, -1.19, 1.04, -0.40 );
73 2         7 $term->( 2, 0, 0, 28.28, 2285.80, -6608.37, 0.00, -589.35, 174.81 );
74 2         6 $term->( 2, 0, 1, 1.64, 3.37, -12.93, 0.00, 2.89, 11.10 );
75 2         7 $term->( 2, 0, 2, 0.00, 0.00, 0.00, 0.00, 0.10, -0.03 );
76 2         8 $term->( 3, 0, 0, 5.31, 189.29, -461.81, 0.00, -61.98, 18.53 );
77 2         8 $term->( 3, 0, 1, 0.31, 0.35, -1.36, 0.00, 0.25, 1.19 );
78 2         6 $term->( 4, 0, 0, 0.81, 17.96, -38.26, 0.00, -6.88, 2.08 );
79 2         7 $term->( 4, 0, 1, 0.05, 0.04, -0.15, 0.00, 0.02, 0.14 );
80 2         7 $term->( 5, 0, 0, 0.11, 1.83, -3.48, 0.00, -0.79, 0.24 );
81 2         5 $term->( 6, 0, 0, 0.02, 0.20, -0.34, 0.00, -0.09, 0.03 );
82 2         7 $term->( -1, -1, 0, 0.09, 0.06, 0.14, -0.22, 0.02, -0.02 );
83 2         6 $term->( 0, -1, 0, 0.72, 0.49, 1.55, -2.31, 0.12, -0.10 );
84 2         7 $term->( 1, -1, 0, 7.00, 4.92, 13.93, -20.48, 0.08, -0.13 );
85 2         8 $term->( 2, -1, 0, 13.08, 4.89, -4.53, 10.01, -0.05, 0.13 );
86 2         8 $term->( 2, -2, 0, 0.14, 0.05, -0.48, -2.66, 0.01, 0.14 );
87 2         6 $term->( 3, -1, 0, 1.38, 0.56, -2.00, 4.85, -0.01, 0.19 );
88 2         6 $term->( 3, -2, 0, -6.85, 2.68, 8.38, 21.42, 0.00, 0.03 );
89 2         6 $term->( 3, -3, 0, -0.08, 0.20, 1.20, 0.46, 0.00, 0.00 );
90 2         6 $term->( 4, -1, 0, 0.16, 0.07, -0.19, 0.47, -0.01, 0.05 );
91 2         6 $term->( 4, -2, 0, -4.41, 2.14, -3.33, -7.21, -0.07, -0.09 );
92 2         7 $term->( 4, -3, 0, -0.12, 0.33, 2.22, 0.72, -0.03, -0.02 );
93 2         7 $term->( 4, -4, 0, -0.04, -0.06, -0.36, 0.23, 0.00, 0.00 );
94 2         8 $term->( 5, -2, 0, -0.44, 0.21, -0.70, -1.46, -0.06, -0.07 );
95 2         6 $term->( 5, -3, 0, 0.48, -2.60, -7.25, -1.37, 0.00, 0.00 );
96 2         16 $term->( 5, -4, 0, -0.09, -0.12, -0.66, 0.50, 0.00, 0.00 );
97 2         7 $term->( 5, -5, 0, 0.03, 0.00, 0.01, -0.17, 0.00, 0.00 );
98 2         7 $term->( 6, -2, 0, -0.05, 0.03, -0.07, -0.15, -0.01, -0.01 );
99 2         6 $term->( 6, -3, 0, 0.10, -0.96, 2.36, 0.30, 0.04, 0.00 );
100 2         6 $term->( 6, -4, 0, -0.17, -0.20, -1.09, 0.94, 0.02, -0.02 );
101 2         8 $term->( 6, -5, 0, 0.05, 0.00, 0.00, -0.30, 0.00, 0.00 );
102 2         7 $term->( 7, -3, 0, 0.01, -0.10, 0.32, 0.04, 0.02, 0.00 );
103 2         7 $term->( 7, -4, 0, 0.86, 0.77, 1.86, -2.01, 0.01, -0.01 );
104 2         5 $term->( 7, -5, 0, 0.09, -0.01, -0.05, -0.44, 0.00, 0.00 );
105 2         8 $term->( 7, -6, 0, -0.01, 0.02, 0.10, 0.08, 0.00, 0.00 );
106 2         6 $term->( 8, -4, 0, 0.20, 0.16, -0.53, 0.64, -0.01, 0.02 );
107 2         6 $term->( 8, -5, 0, 0.17, -0.03, -0.14, -0.84, 0.00, 0.01 );
108 2         85 $term->( 8, -6, 0, -0.02, 0.03, 0.16, 0.09, 0.00, 0.00 );
109 2         9 $term->( 9, -5, 0, -0.55, 0.15, 0.30, 1.10, 0.00, 0.00 );
110 2         5 $term->( 9, -6, 0, -0.02, 0.04, 0.20, 0.10, 0.00, 0.00 );
111 2         8 $term->( 10, -5, 0, -0.09, 0.03, -0.10, -0.33, 0.00, -0.01 );
112 2         7 $term->( 10, -6, 0, -0.05, 0.11, 0.48, 0.21, -0.01, 0.00 );
113 2         6 $term->( 11, -6, 0, 0.10, -0.35, -0.52, -0.15, 0.00, 0.00 );
114 2         61 $term->( 11, -7, 0, -0.01, -0.02, -0.10, 0.07, 0.00, 0.00 );
115 2         11 $term->( 12, -6, 0, 0.01, -0.04, 0.18, 0.04, 0.01, 0.00 );
116 2         8 $term->( 12, -7, 0, -0.05, -0.07, -0.29, 0.20, 0.01, 0.00 );
117 2         14 $term->( 13, -7, 0, 0.23, 0.27, 0.25, -0.21, 0.00, 0.00 );
118 2         6 $term->( 14, -7, 0, 0.02, 0.03, -0.10, 0.09, 0.00, 0.00 );
119 2         6 $term->( 14, -8, 0, 0.05, 0.01, 0.03, -0.23, 0.00, 0.03 );
120 2         6 $term->( 15, -8, 0, -1.53, 0.27, 0.06, 0.42, 0.00, 0.00 );
121 2         8 $term->( 16, -8, 0, -0.14, 0.02, -0.10, -0.55, -0.01, -0.02 );
122 2         8 $term->( 16, -9, 0, 0.03, -0.06, -0.25, -0.11, 0.00, 0.00 );
123              
124             # Perturbations by Mars
125 2         6 $term = pert(
126             T => $t,
127             M => $m4,
128             m => $m5,
129             I_min => -2,
130             I_max => 5,
131             i_min => -5,
132             i_max => -1,
133             callback => $pert_cb
134             );
135              
136 2         10 $term->( -2, -1, 0, 0.05, 0.03, 0.08, -0.14, 0.01, -0.01 );
137 2         8 $term->( -1, -1, 0, 0.39, 0.27, 0.92, -1.50, -0.03, -0.06 );
138 2         7 $term->( -1, -2, 0, -0.16, 0.03, 0.13, 0.67, -0.01, 0.06 );
139 2         8 $term->( -1, -3, 0, -0.02, 0.01, 0.05, 0.09, 0.00, 0.01 );
140 2         7 $term->( 0, -1, 0, 3.56, 1.13, -5.41, -7.18, -0.25, -0.24 );
141 2         7 $term->( 0, -2, 0, -1.44, 0.25, 1.24, 7.96, 0.02, 0.31 );
142 2         7 $term->( 0, -3, 0, -0.21, 0.11, 0.55, 1.04, 0.01, 0.05 );
143 2         5 $term->( 0, -4, 0, -0.02, 0.02, 0.11, 0.11, 0.00, 0.01 );
144 2         6 $term->( 1, -1, 0, 16.67, -19.15, 61.00, 53.36, -0.06, -0.07 );
145 2         5 $term->( 1, -2, 0, -21.64, 3.18, -7.77, -54.64, -0.31, 0.50 );
146 2         6 $term->( 1, -3, 0, -2.82, 1.45, -2.53, -5.73, 0.01, 0.07 );
147 2         6 $term->( 1, -4, 0, -0.31, 0.28, -0.34, -0.51, 0.00, 0.00 );
148 2         7 $term->( 2, -1, 0, 2.15, -2.29, 7.04, 6.94, 0.33, 0.19 );
149 2         9 $term->( 2, -2, 0, -15.69, 3.31, -15.70, -73.17, -0.17, -0.25 );
150 2         8 $term->( 2, -3, 0, -1.73, 1.95, -9.19, -7.20, 0.02, -0.03 );
151 2         6 $term->( 2, -4, 0, -0.01, 0.33, -1.42, 0.08, 0.01, -0.01 );
152 2         6 $term->( 2, -5, 0, 0.03, 0.03, -0.13, 0.12, 0.00, 0.00 );
153 2         6 $term->( 3, -1, 0, 0.26, -0.28, 0.73, 0.71, 0.08, 0.04 );
154 2         7 $term->( 3, -2, 0, -2.06, 0.46, -1.61, -6.72, -0.13, -0.25 );
155 2         8 $term->( 3, -3, 0, -1.28, -0.27, 2.21, -6.90, -0.04, -0.02 );
156 2         6 $term->( 3, -4, 0, -0.22, 0.08, -0.44, -1.25, 0.00, 0.01 );
157 2         6 $term->( 3, -5, 0, -0.02, 0.03, -0.15, -0.08, 0.00, 0.00 );
158 2         10 $term->( 4, -1, 0, 0.03, -0.03, 0.08, 0.08, 0.01, 0.01 );
159 2         7 $term->( 4, -2, 0, -0.26, 0.06, -0.17, -0.70, -0.03, -0.05 );
160 2         8 $term->( 4, -3, 0, -0.20, -0.05, 0.22, -0.79, -0.01, -0.02 );
161 2         7 $term->( 4, -4, 0, -0.11, -0.14, 0.93, -0.60, 0.00, 0.00 );
162 2         7 $term->( 4, -5, 0, -0.04, -0.02, 0.09, -0.23, 0.00, 0.00 );
163 2         5 $term->( 5, -4, 0, -0.02, -0.03, 0.13, -0.09, 0.00, 0.00 );
164 2         7 $term->( 5, -5, 0, 0.00, -0.03, 0.21, 0.01, 0.00, 0.00 );
165              
166             # Perturbations by Saturn
167 2         6 $term = pert(
168             T => $t,
169             M => $m4,
170             m => $m6,
171             I_min => -1,
172             I_max => 3,
173             i_min => -4,
174             i_max => -1,
175             callback => $pert_cb
176             );
177              
178 2         9 $term->( -1, -1, 0, 0.03, 0.13, 0.48, -0.13, 0.02, 0.00 );
179 2         6 $term->( 0, -1, 0, 0.27, 0.84, 0.40, -0.43, 0.01, -0.01 );
180 2         7 $term->( 0, -2, 0, 0.12, -0.04, -0.33, -0.55, -0.01, -0.02 );
181 2         7 $term->( 0, -3, 0, 0.02, -0.01, -0.07, -0.08, 0.00, 0.00 );
182 2         7 $term->( 1, -1, 0, 1.12, 0.76, -2.66, 3.91, -0.01, 0.01 );
183 2         7 $term->( 1, -2, 0, 1.49, -0.95, 3.07, 4.83, 0.04, -0.05 );
184 2         6 $term->( 1, -3, 0, 0.21, -0.18, 0.55, 0.64, 0.00, 0.00 );
185 2         7 $term->( 2, -1, 0, 0.12, 0.10, -0.29, 0.34, -0.01, 0.02 );
186 2         7 $term->( 2, -2, 0, 0.51, -0.36, 1.61, 2.25, 0.03, 0.01 );
187 2         6 $term->( 2, -3, 0, 0.10, -0.10, 0.50, 0.43, 0.00, 0.00 );
188 2         6 $term->( 2, -4, 0, 0.01, -0.02, 0.11, 0.05, 0.00, 0.00 );
189 2         7 $term->( 3, -2, 0, 0.07, -0.05, 0.16, 0.22, 0.01, 0.01 );
190              
191             # Ecliptic coordinates ([rad],[AU])
192 2         10 $dl +=
193             +52.49 * sin( pi2 * ( 0.1868 + 0.0549 * $t ) ) +
194             0.61 * sin( pi2 * ( 0.9220 + 0.3307 * $t ) ) +
195             0.32 * sin( pi2 * ( 0.4731 + 2.1485 * $t ) ) +
196             0.28 * sin( pi2 * ( 0.9467 + 0.1133 * $t ) );
197 2         4 $dl += +0.14 + 0.87 * $t - 0.11 * $t * $t;
198              
199 2         10 my $l =
200             pi2 *
201             frac( 0.9334591 + $m4 / pi2 +
202             ( ( 6615.5 + 1.1 * $t ) * $t + $dl ) / 1296.0E3 );
203 2         8 my $r = 1.5303352 + 0.0000131 * $t + $dr * 1.0E-6;
204 2         7 my $b = ( 596.32 + ( -2.92 - 0.10 * $t ) * $t + $db ) / ARCS;
205              
206 2         19 $l, $b, $r;
207             }
208              
209             # Intermediate variables for calculating geocentric positions.
210             sub _lbr_geo {
211 2     2   6 my ( $self, $t ) = @_;
212              
213 2         6 my $m = pi2 * frac( 0.0538553 + 53.1662736 * $t );
214 2         5 my $c2m = cos( 2 * $m );
215 2         4 my $sm = sin($m);
216 2         4 my $cm = cos($m);
217              
218 2         6 my $dl = 91.50 + 17.07 * $cm + 2.03 * $c2m;
219 2         3 my $dr = 12.98 * $sm + 1.21 * $c2m;
220 2         5 my $db = 0.83 * $cm + 2.80 * $sm;
221              
222 2         7 $dl, $db, $dr;
223             }
224              
225             1;
226              
227             __END__
228              
229             =pod
230              
231             =encoding UTF-8
232              
233             =head1 NAME
234              
235             Astro::Montenbruck::Ephemeris::Planet::Mars - Mars.
236              
237             =head1 SYNOPSIS
238              
239             use Astro::Montenbruck::Ephemeris::Planet::Mars;
240             my $planet = Astro::Montenbruck::Ephemeris::Planet::Mars->new();
241             my @geo = $planet->position($t); # apparent geocentric ecliptical coordinates
242              
243             =head1 DESCRIPTION
244              
245             Child class of L<Astro::Montenbruck::Ephemeris::Planet>, responsible for calculating
246             B<Mars> position.
247              
248             =head1 METHODS
249              
250             =head2 Astro::Montenbruck::Ephemeris::Planet::Mars->new
251              
252             Constructor.
253              
254             =head2 $self->heliocentric($t)
255              
256             See description in L<Astro::Montenbruck::Ephemeris::Planet>.
257              
258             =head1 AUTHOR
259              
260             Sergey Krushinsky, C<< <krushi at cpan.org> >>
261              
262             =head1 COPYRIGHT AND LICENSE
263              
264             Copyright (C) 2009-2019 by Sergey Krushinsky
265              
266             This library is free software; you can redistribute it and/or modify
267             it under the same terms as Perl itself.
268              
269             =cut