File Coverage

lib/Astro/Montenbruck/Ephemeris/Planet/Pluto.pm
Criterion Covered Total %
statement 105 105 100.0
branch 2 2 100.0
condition n/a
subroutine 13 13 100.0
pod 2 2 100.0
total 122 122 100.0


line stmt bran cond sub pod time code
1             package Astro::Montenbruck::Ephemeris::Planet::Pluto;
2              
3 2     2   1271 use strict;
  2         6  
  2         66  
4 2     2   11 use warnings;
  2         5  
  2         68  
5              
6 2     2   12 use POSIX qw/atan/;
  2         4  
  2         26  
7 2     2   189 use Math::Trig qw/:pi deg2rad/;
  2         4  
  2         276  
8 2     2   14 use base qw/Astro::Montenbruck::Ephemeris::Planet/;
  2         4  
  2         214  
9 2     2   15 use Astro::Montenbruck::Ephemeris::Planet qw/$PL/;
  2         5  
  2         174  
10              
11 2     2   15 use Astro::Montenbruck::Ephemeris::Pert qw/pert/;
  2         5  
  2         113  
12 2     2   14 use Astro::Montenbruck::MathUtils qw /frac ARCS/;
  2         13  
  2         2054  
13              
14             our $VERSION = 0.01;
15              
16             sub new {
17 7     7 1 16 my $class = shift;
18 7         34 $class->SUPER::new( id => $PL );
19             }
20              
21              
22             sub heliocentric {
23 7     7 1 19 my ( $self, $t ) = @_;
24              
25             # Mean anomalies of planets in [rad]
26 7         25 my $m5 = pi2 * frac( 0.0565314 + 8.4302963 * $t );
27 7         19 my $m6 = pi2 * frac( 0.8829867 + 3.3947688 * $t );
28 7         19 my $m9 = pi2 * frac( 0.0385795 + 0.4026667 * $t );
29              
30 7         18 my ( $dl, $dr, $db ) = ( 0, 0, 0 ); # Corrections in longitude ["],
31 7     182   26 my $pert_cb = sub { $dl += $_[0]; $dr += $_[1]; $db += $_[2] };
  182         281  
  182         253  
  182         275  
32              
33             # Perturbations by Pluto
34 7         31 my $term = pert(
35             T => $t,
36             M => $m9,
37             m => $m5,
38             I_min => 0,
39             I_max => 6,
40             i_min => -2,
41             i_max => 1,
42             callback => $pert_cb
43             );
44              
45 7         32 $term->( 1, 0, 0, 0.06, 100924.08, -960396.0, 15965.1, 51987.68, -24288.76 );
46 7         31 $term->( 2, 0, 0, 3274.74, 17835.12, -118252.2, 3632.4, 12687.49, -6049.72 );
47 7         27 $term->( 3, 0, 0, 1543.52, 4631.99, -21446.6, 1167.0, 3504.00, -1853.10 );
48 7         27 $term->( 4, 0, 0, 688.99, 1227.08, -4823.4, 213.5, 1048.19, -648.26 );
49 7         26 $term->( 5, 0, 0, 242.27, 415.93, -1075.4, 140.6, 302.33, -209.76 );
50 7         21 $term->( 6, 0, 0, 138.41, 110.91, -308.8, -55.3, 109.52, -93.82 );
51 7         22 $term->( 3, -1, 0, -0.99, 5.06, -25.6, 19.8, 1.26, -1.96 );
52 7         25 $term->( 2, -1, 0, 7.15, 5.61, -96.7, 57.2, 1.64, -2.16 );
53 7         23 $term->( 1, -1, 0, 10.79, 23.13, -390.4, 236.4, -0.33, 0.86 );
54 7         24 $term->( 0, 1, 0, -0.23, 4.43, 102.8, 63.2, 3.15, 0.34 );
55 7         24 $term->( 1, 1, 0, -1.10, -0.92, 11.8, -2.3, 0.43, 0.14 );
56 7         23 $term->( 2, 1, 0, 0.62, 0.84, 2.3, 0.7, 0.05, -0.04 );
57 7         21 $term->( 3, 1, 0, -0.38, -0.45, 1.2, -0.8, 0.04, 0.05 );
58 7         18 $term->( 4, 1, 0, 0.17, 0.25, 0.0, 0.2, -0.01, -0.01 );
59 7         23 $term->( 3, -2, 0, 0.06, 0.07, -0.6, 0.3, 0.03, -0.03 );
60 7         21 $term->( 2, -2, 0, 0.13, 0.20, -2.2, 1.5, 0.03, -0.07 );
61 7         21 $term->( 1, -2, 0, 0.32, 0.49, -9.4, 5.7, -0.01, 0.03 );
62 7         59 $term->( 0, -2, 0, -0.04, -0.07, 2.6, -1.5, 0.07, -0.02 );
63              
64             # Perturbations by Saturn
65 7         23 $term = pert(
66             T => $t,
67             M => $m9,
68             m => $m6,
69             I_min => 0,
70             I_max => 3,
71             i_min => -2,
72             i_max => 1,
73             callback => $pert_cb
74             );
75              
76 7         32 $term->( 1, -1, 0, -29.47, 75.97, -106.4, -204.9, -40.71, -17.55 );
77 7         25 $term->( 0, 1, 0, -13.88, 18.20, 42.6, -46.1, 1.13, 0.43 );
78 7         21 $term->( 1, 1, 0, 5.81, -23.48, 15.0, -6.8, -7.48, 3.07 );
79 7         29 $term->( 2, 1, 0, -10.27, 14.16, -7.9, 0.4, 2.43, -0.09 );
80 7         27 $term->( 3, 1, 0, 6.86, -10.66, 7.3, -0.3, -2.25, 0.69 );
81 7         29 $term->( 2, -2, 0, 4.32, 2.00, 0.0, -2.2, -0.24, 0.12 );
82 7         30 $term->( 1, -2, 0, -5.04, -0.83, -9.2, -3.1, 0.79, -0.24 );
83 7         22 $term->( 0, -2, 0, 4.25, 2.48, -5.9, -3.3, 0.58, 0.02 );
84              
85             # Perturbations by Pluto and Saturn
86 7         16 my $phi = ( $m5 - $m6 );
87 7         14 my $c = cos($phi);
88 7         12 my $s = sin($phi);
89 7         16 $dl += -9.11 * $c + 0.12 * $s;
90 7         16 $dr += -3.4 * $c - 3.3 * $s;
91 7         28 $db += +0.81 * $c + 0.78 * $s;
92              
93 7         12 $phi = ( $m5 - $m6 + $m9 );
94 7         13 $c = cos($phi);
95 7         10 $s = sin($phi);
96 7         14 $dl += +5.92 * $c + 0.25 * $s;
97 7         11 $dr += +2.3 * $c - 3.8 * $s;
98 7         13 $db += -0.67 * $c - 0.51 * $s;
99              
100             # Ecliptic coordinates ([rad],[AU])
101 7         28 my $l = pi2 * frac( 0.6232469 + $m9 / pi2 + $dl / 1296.0E3 );
102 7         16 my $r = 40.7247248 + $dr * 1.0E-5;
103 7         22 my $b = deg2rad(-3.909434) + $db / ARCS;
104              
105             # Position vector; ecliptic and equinox of B1950.0
106 7         74 ( $l, $b ) = _prec( $t, $l, $b );
107              
108 7         63 $l, $b, $r;
109             }
110              
111             # Intermediate variables for calculating geocentric positions.
112             sub _lbr_geo {
113 7     7   22 my ( $self, $t ) = @_;
114              
115 7         19 my $m = pi2 * frac( 0.0385795 + 0.4026667 * $t );
116 7         23 my $dl =
117             0.69 + 0.34 * cos($m) + 0.12 * cos( 2 * $m ) + 0.05 * cos( 3 * $m );
118 7         17 my $dr = 6.66 * sin($m) + 1.64 * sin( 2 * $m );
119 7         18 my $db = -0.08 * cos($m) - 0.17 * sin($m) - 0.09 * sin( 2 * $m );
120              
121 7         20 $dl, $db, $dr;
122             }
123              
124             sub _prec {
125 7     7   17 my ( $t, $l, $b ) = @_;
126              
127 7         13 my $d = $t + 0.5;
128 7         13 my $ppi = 3.044;
129              
130 7         11 my $pk = 2.28E-4 * $d;
131 7         14 my $p = ( 0.0243764 + 5.39E-6 * $d ) * $d;
132 7         14 my $c1 = cos($pk);
133 7         11 my $c2 = cos($b);
134 7         18 my $c3 = cos( $ppi - $l );
135 7         13 my $s1 = sin($pk);
136 7         14 my $s2 = sin($b);
137 7         12 my $s3 = sin( $ppi - $l );
138 7         11 my $x = $c2 * $c3;
139 7         13 my $y = $c1 * $c2 * $s3 - $s1 * $s2;
140 7         15 my $z = $s1 * $c2 * $s3 + $c1 * $s2;
141              
142 7         33 $b = atan( $z / sqrt( ( 1.0 - $z ) * ( 1.0 + $z ) ) );
143 7 100       22 if ( $x > 0 ) {
144 5         22 $l = pi2 * frac( ( $ppi + $p - atan( $y / $x ) ) / pi2 );
145             }
146             else {
147 2         10 $l = pi2 * frac( ( $ppi + $p - atan( $y / $x ) ) / pi2 + 0.5 );
148             }
149              
150 7         20 $l, $b;
151             }
152              
153             1;
154              
155             __END__
156              
157             =pod
158              
159             =encoding UTF-8
160              
161             =head1 NAME
162              
163             Astro::Montenbruck::Ephemeris::Planet::Pluto - Pluto.
164              
165             =head1 SYNOPSIS
166              
167             use Astro::Montenbruck::Ephemeris::Planet::Pluto;
168             my $planet = Astro::Montenbruck::Ephemeris::Planet::Pluto->new();
169             my @geo = $planet->position($t); # apparent geocentric ecliptical coordinates
170              
171             =head1 DESCRIPTION
172              
173             Child class of L<Astro::Montenbruck::Ephemeris::Planet>, responsible for calculating
174             B<Pluto> position.
175              
176             The coordinates are first calculated relative to the fixed ecliptic of 1950, and
177             then transformed to the equinox of date. This method is nesessary because of
178             the high inclination of Pluto's orbit.
179              
180             =head1 CAVEATS
181              
182             The routine is applicable only between years B<1890> and B<2100>.
183              
184             The reason for this is that the series expansion used was not derived from
185             perturbation theory, but from a Fourier analysis of a numerically integrated
186             ephemeris covering this period of time. Even a few years before 1890 or after
187             2100, the errors in the calculated coordinates grow very sharply, reaqching
188             values of more than 0.5 arc-degrees.
189              
190             — O.Montenbruck, Th.Pfleger "Astronomy on the Personal Computer"
191              
192             =head1 METHODS
193              
194             =head2 Astro::Montenbruck::Ephemeris::Planet::Pluto->new
195              
196             Constructor.
197              
198             =head2 $self->heliocentric($t)
199              
200             See description in L<Astro::Montenbruck::Ephemeris::Planet>.
201              
202             =head1 AUTHOR
203              
204             Sergey Krushinsky, C<< <krushi at cpan.org> >>
205              
206             =head1 COPYRIGHT AND LICENSE
207              
208             Copyright (C) 2009-2019 by Sergey Krushinsky
209              
210             This library is free software; you can redistribute it and/or modify
211             it under the same terms as Perl itself.
212              
213             =cut