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 2     2   1056 use strict;
  2         5  
  2         63  
4 2     2   12 use warnings;
  2         4  
  2         57  
5              
6 2     2   9 use base qw/Astro::Montenbruck::Ephemeris::Planet/;
  2         3  
  2         133  
7              
8 2     2   11 use Math::Trig qw/:pi/;
  2         3  
  2         248  
9 2     2   12 use Astro::Montenbruck::Ephemeris::Pert qw /pert/;
  2         3  
  2         86  
10 2     2   11 use Astro::Montenbruck::MathUtils qw /frac ARCS/;
  2         4  
  2         96  
11 2     2   12 use Astro::Montenbruck::Ephemeris::Planet qw/$MA/;
  2         3  
  2         2791  
12              
13             our $VERSION = 0.01;
14              
15             sub new {
16 4     4 1 8 my $class = shift;
17 4         18 $class->SUPER::new( id => $MA );
18             }
19              
20             sub heliocentric {
21 4     4 1 10 my ( $self, $t ) = @_;
22              
23             # Mean anomalies of planets in [rad]
24 4         11 my $m2 = pi2 * frac( 0.1382208 + 162.5482542 * $t );
25 4         11 my $m3 = pi2 * frac( 0.9926208 + 99.9970236 * $t );
26 4         11 my $m4 = pi2 * frac( 0.0538553 + 53.1662736 * $t );
27 4         10 my $m5 = pi2 * frac( 0.0548944 + 8.4290611 * $t );
28 4         10 my $m6 = pi2 * frac( 0.8811167 + 3.3935250 * $t );
29              
30 4         8 my ( $dl, $dr, $db ) = ( 0, 0, 0 ); # Corrections in longitude ["],
31 4     424   15 my $pert_cb = sub { $dl += $_[0]; $dr += $_[1]; $db += $_[2] };
  424         495  
  424         465  
  424         574  
32              
33             # Perturbations by Venus
34 4         12 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 4         18 $term->( 0, -1, 0, -0.01, -0.03, 0.10, -0.04, 0.00, 0.00 );
46 4         15 $term->( 1, -1, 0, 0.05, 0.10, -2.08, 0.75, 0.00, 0.00 );
47 4         35 $term->( 2, -1, 0, -0.25, -0.57, -2.58, 1.18, 0.05, -0.04 );
48 4         16 $term->( 2, -2, 0, 0.02, 0.02, 0.13, -0.14, 0.00, 0.00 );
49 4         12 $term->( 3, -1, 0, 3.41, 5.38, 1.87, -1.15, 0.01, -0.01 );
50 4         12 $term->( 3, -2, 0, 0.02, 0.02, 0.11, -0.13, 0.00, 0.00 );
51 4         11 $term->( 4, -1, 0, 0.32, 0.49, -1.88, 1.21, -0.07, 0.07 );
52 4         10 $term->( 4, -2, 0, 0.03, 0.03, 0.12, -0.14, 0.00, 0.00 );
53 4         11 $term->( 5, -1, 0, 0.04, 0.06, -0.17, 0.11, -0.01, 0.01 );
54 4         14 $term->( 5, -2, 0, 0.11, 0.09, 0.35, -0.43, -0.01, 0.01 );
55 4         17 $term->( 6, -2, 0, -0.36, -0.28, -0.20, 0.25, 0.00, 0.00 );
56 4         12 $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 4         11 $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 4         16 $term->( 1, 0, 0, -5.32, 38481.97, -141856.04, 0.40, -6321.67, 1876.89 );
71 4         10 $term->( 1, 0, 1, -1.12, 37.98, -138.67, -2.93, 37.28, 117.48 );
72 4         11 $term->( 1, 0, 2, -0.32, -0.03, 0.12, -1.19, 1.04, -0.40 );
73 4         9 $term->( 2, 0, 0, 28.28, 2285.80, -6608.37, 0.00, -589.35, 174.81 );
74 4         73 $term->( 2, 0, 1, 1.64, 3.37, -12.93, 0.00, 2.89, 11.10 );
75 4         10 $term->( 2, 0, 2, 0.00, 0.00, 0.00, 0.00, 0.10, -0.03 );
76 4         12 $term->( 3, 0, 0, 5.31, 189.29, -461.81, 0.00, -61.98, 18.53 );
77 4         10 $term->( 3, 0, 1, 0.31, 0.35, -1.36, 0.00, 0.25, 1.19 );
78 4         64 $term->( 4, 0, 0, 0.81, 17.96, -38.26, 0.00, -6.88, 2.08 );
79 4         14 $term->( 4, 0, 1, 0.05, 0.04, -0.15, 0.00, 0.02, 0.14 );
80 4         11 $term->( 5, 0, 0, 0.11, 1.83, -3.48, 0.00, -0.79, 0.24 );
81 4         12 $term->( 6, 0, 0, 0.02, 0.20, -0.34, 0.00, -0.09, 0.03 );
82 4         14 $term->( -1, -1, 0, 0.09, 0.06, 0.14, -0.22, 0.02, -0.02 );
83 4         11 $term->( 0, -1, 0, 0.72, 0.49, 1.55, -2.31, 0.12, -0.10 );
84 4         10 $term->( 1, -1, 0, 7.00, 4.92, 13.93, -20.48, 0.08, -0.13 );
85 4         13 $term->( 2, -1, 0, 13.08, 4.89, -4.53, 10.01, -0.05, 0.13 );
86 4         10 $term->( 2, -2, 0, 0.14, 0.05, -0.48, -2.66, 0.01, 0.14 );
87 4         11 $term->( 3, -1, 0, 1.38, 0.56, -2.00, 4.85, -0.01, 0.19 );
88 4         11 $term->( 3, -2, 0, -6.85, 2.68, 8.38, 21.42, 0.00, 0.03 );
89 4         10 $term->( 3, -3, 0, -0.08, 0.20, 1.20, 0.46, 0.00, 0.00 );
90 4         10 $term->( 4, -1, 0, 0.16, 0.07, -0.19, 0.47, -0.01, 0.05 );
91 4         11 $term->( 4, -2, 0, -4.41, 2.14, -3.33, -7.21, -0.07, -0.09 );
92 4         10 $term->( 4, -3, 0, -0.12, 0.33, 2.22, 0.72, -0.03, -0.02 );
93 4         11 $term->( 4, -4, 0, -0.04, -0.06, -0.36, 0.23, 0.00, 0.00 );
94 4         14 $term->( 5, -2, 0, -0.44, 0.21, -0.70, -1.46, -0.06, -0.07 );
95 4         12 $term->( 5, -3, 0, 0.48, -2.60, -7.25, -1.37, 0.00, 0.00 );
96 4         12 $term->( 5, -4, 0, -0.09, -0.12, -0.66, 0.50, 0.00, 0.00 );
97 4         12 $term->( 5, -5, 0, 0.03, 0.00, 0.01, -0.17, 0.00, 0.00 );
98 4         17 $term->( 6, -2, 0, -0.05, 0.03, -0.07, -0.15, -0.01, -0.01 );
99 4         12 $term->( 6, -3, 0, 0.10, -0.96, 2.36, 0.30, 0.04, 0.00 );
100 4         12 $term->( 6, -4, 0, -0.17, -0.20, -1.09, 0.94, 0.02, -0.02 );
101 4         12 $term->( 6, -5, 0, 0.05, 0.00, 0.00, -0.30, 0.00, 0.00 );
102 4         10 $term->( 7, -3, 0, 0.01, -0.10, 0.32, 0.04, 0.02, 0.00 );
103 4         12 $term->( 7, -4, 0, 0.86, 0.77, 1.86, -2.01, 0.01, -0.01 );
104 4         11 $term->( 7, -5, 0, 0.09, -0.01, -0.05, -0.44, 0.00, 0.00 );
105 4         12 $term->( 7, -6, 0, -0.01, 0.02, 0.10, 0.08, 0.00, 0.00 );
106 4         10 $term->( 8, -4, 0, 0.20, 0.16, -0.53, 0.64, -0.01, 0.02 );
107 4         10 $term->( 8, -5, 0, 0.17, -0.03, -0.14, -0.84, 0.00, 0.01 );
108 4         48 $term->( 8, -6, 0, -0.02, 0.03, 0.16, 0.09, 0.00, 0.00 );
109 4         11 $term->( 9, -5, 0, -0.55, 0.15, 0.30, 1.10, 0.00, 0.00 );
110 4         10 $term->( 9, -6, 0, -0.02, 0.04, 0.20, 0.10, 0.00, 0.00 );
111 4         11 $term->( 10, -5, 0, -0.09, 0.03, -0.10, -0.33, 0.00, -0.01 );
112 4         11 $term->( 10, -6, 0, -0.05, 0.11, 0.48, 0.21, -0.01, 0.00 );
113 4         10 $term->( 11, -6, 0, 0.10, -0.35, -0.52, -0.15, 0.00, 0.00 );
114 4         10 $term->( 11, -7, 0, -0.01, -0.02, -0.10, 0.07, 0.00, 0.00 );
115 4         10 $term->( 12, -6, 0, 0.01, -0.04, 0.18, 0.04, 0.01, 0.00 );
116 4         12 $term->( 12, -7, 0, -0.05, -0.07, -0.29, 0.20, 0.01, 0.00 );
117 4         12 $term->( 13, -7, 0, 0.23, 0.27, 0.25, -0.21, 0.00, 0.00 );
118 4         11 $term->( 14, -7, 0, 0.02, 0.03, -0.10, 0.09, 0.00, 0.00 );
119 4         10 $term->( 14, -8, 0, 0.05, 0.01, 0.03, -0.23, 0.00, 0.03 );
120 4         9 $term->( 15, -8, 0, -1.53, 0.27, 0.06, 0.42, 0.00, 0.00 );
121 4         22 $term->( 16, -8, 0, -0.14, 0.02, -0.10, -0.55, -0.01, -0.02 );
122 4         11 $term->( 16, -9, 0, 0.03, -0.06, -0.25, -0.11, 0.00, 0.00 );
123              
124             # Perturbations by Mars
125 4         17 $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 4         17 $term->( -2, -1, 0, 0.05, 0.03, 0.08, -0.14, 0.01, -0.01 );
137 4         15 $term->( -1, -1, 0, 0.39, 0.27, 0.92, -1.50, -0.03, -0.06 );
138 4         13 $term->( -1, -2, 0, -0.16, 0.03, 0.13, 0.67, -0.01, 0.06 );
139 4         13 $term->( -1, -3, 0, -0.02, 0.01, 0.05, 0.09, 0.00, 0.01 );
140 4         11 $term->( 0, -1, 0, 3.56, 1.13, -5.41, -7.18, -0.25, -0.24 );
141 4         10 $term->( 0, -2, 0, -1.44, 0.25, 1.24, 7.96, 0.02, 0.31 );
142 4         16 $term->( 0, -3, 0, -0.21, 0.11, 0.55, 1.04, 0.01, 0.05 );
143 4         9 $term->( 0, -4, 0, -0.02, 0.02, 0.11, 0.11, 0.00, 0.01 );
144 4         11 $term->( 1, -1, 0, 16.67, -19.15, 61.00, 53.36, -0.06, -0.07 );
145 4         13 $term->( 1, -2, 0, -21.64, 3.18, -7.77, -54.64, -0.31, 0.50 );
146 4         9 $term->( 1, -3, 0, -2.82, 1.45, -2.53, -5.73, 0.01, 0.07 );
147 4         20 $term->( 1, -4, 0, -0.31, 0.28, -0.34, -0.51, 0.00, 0.00 );
148 4         11 $term->( 2, -1, 0, 2.15, -2.29, 7.04, 6.94, 0.33, 0.19 );
149 4         13 $term->( 2, -2, 0, -15.69, 3.31, -15.70, -73.17, -0.17, -0.25 );
150 4         11 $term->( 2, -3, 0, -1.73, 1.95, -9.19, -7.20, 0.02, -0.03 );
151 4         12 $term->( 2, -4, 0, -0.01, 0.33, -1.42, 0.08, 0.01, -0.01 );
152 4         12 $term->( 2, -5, 0, 0.03, 0.03, -0.13, 0.12, 0.00, 0.00 );
153 4         10 $term->( 3, -1, 0, 0.26, -0.28, 0.73, 0.71, 0.08, 0.04 );
154 4         12 $term->( 3, -2, 0, -2.06, 0.46, -1.61, -6.72, -0.13, -0.25 );
155 4         13 $term->( 3, -3, 0, -1.28, -0.27, 2.21, -6.90, -0.04, -0.02 );
156 4         11 $term->( 3, -4, 0, -0.22, 0.08, -0.44, -1.25, 0.00, 0.01 );
157 4         11 $term->( 3, -5, 0, -0.02, 0.03, -0.15, -0.08, 0.00, 0.00 );
158 4         13 $term->( 4, -1, 0, 0.03, -0.03, 0.08, 0.08, 0.01, 0.01 );
159 4         17 $term->( 4, -2, 0, -0.26, 0.06, -0.17, -0.70, -0.03, -0.05 );
160 4         15 $term->( 4, -3, 0, -0.20, -0.05, 0.22, -0.79, -0.01, -0.02 );
161 4         10 $term->( 4, -4, 0, -0.11, -0.14, 0.93, -0.60, 0.00, 0.00 );
162 4         13 $term->( 4, -5, 0, -0.04, -0.02, 0.09, -0.23, 0.00, 0.00 );
163 4         15 $term->( 5, -4, 0, -0.02, -0.03, 0.13, -0.09, 0.00, 0.00 );
164 4         11 $term->( 5, -5, 0, 0.00, -0.03, 0.21, 0.01, 0.00, 0.00 );
165              
166             # Perturbations by Saturn
167 4         14 $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 4         16 $term->( -1, -1, 0, 0.03, 0.13, 0.48, -0.13, 0.02, 0.00 );
179 4         11 $term->( 0, -1, 0, 0.27, 0.84, 0.40, -0.43, 0.01, -0.01 );
180 4         12 $term->( 0, -2, 0, 0.12, -0.04, -0.33, -0.55, -0.01, -0.02 );
181 4         11 $term->( 0, -3, 0, 0.02, -0.01, -0.07, -0.08, 0.00, 0.00 );
182 4         14 $term->( 1, -1, 0, 1.12, 0.76, -2.66, 3.91, -0.01, 0.01 );
183 4         14 $term->( 1, -2, 0, 1.49, -0.95, 3.07, 4.83, 0.04, -0.05 );
184 4         13 $term->( 1, -3, 0, 0.21, -0.18, 0.55, 0.64, 0.00, 0.00 );
185 4         13 $term->( 2, -1, 0, 0.12, 0.10, -0.29, 0.34, -0.01, 0.02 );
186 4         9 $term->( 2, -2, 0, 0.51, -0.36, 1.61, 2.25, 0.03, 0.01 );
187 4         11 $term->( 2, -3, 0, 0.10, -0.10, 0.50, 0.43, 0.00, 0.00 );
188 4         9 $term->( 2, -4, 0, 0.01, -0.02, 0.11, 0.05, 0.00, 0.00 );
189 4         11 $term->( 3, -2, 0, 0.07, -0.05, 0.16, 0.22, 0.01, 0.01 );
190              
191             # Ecliptic coordinates ([rad],[AU])
192 4         14 $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 4         9 $dl += +0.14 + 0.87 * $t - 0.11 * $t * $t;
198              
199 4         13 my $l =
200             pi2 *
201             frac( 0.9334591 + $m4 / pi2 +
202             ( ( 6615.5 + 1.1 * $t ) * $t + $dl ) / 1296.0E3 );
203 4         9 my $r = 1.5303352 + 0.0000131 * $t + $dr * 1.0E-6;
204 4         8 my $b = ( 596.32 + ( -2.92 - 0.10 * $t ) * $t + $db ) / ARCS;
205              
206 4         31 $l, $b, $r;
207             }
208              
209             # Intermediate variables for calculating geocentric positions.
210             sub _lbr_geo {
211 4     4   9 my ( $self, $t ) = @_;
212              
213 4         8 my $m = pi2 * frac( 0.0538553 + 53.1662736 * $t );
214 4         10 my $c2m = cos( 2 * $m );
215 4         5 my $sm = sin($m);
216 4         6 my $cm = cos($m);
217              
218 4         8 my $dl = 91.50 + 17.07 * $cm + 2.03 * $c2m;
219 4         7 my $dr = 12.98 * $sm + 1.21 * $c2m;
220 4         6 my $db = 0.83 * $cm + 2.80 * $sm;
221              
222 4         10 $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-2022 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