File Coverage

lib/Astro/Montenbruck/Ephemeris/Planet/Neptune.pm
Criterion Covered Total %
statement 81 81 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 2 2 100.0
total 94 94 100.0


line stmt bran cond sub pod time code
1             package Astro::Montenbruck::Ephemeris::Planet::Neptune;
2              
3 2     2   966 use strict;
  2         4  
  2         801  
4 2     2   11 use warnings;
  2         4  
  2         51  
5              
6 2     2   10 use base qw/Astro::Montenbruck::Ephemeris::Planet/;
  2         4  
  2         144  
7 2     2   11 use Math::Trig qw/:pi/;
  2         4  
  2         198  
8 2     2   12 use Astro::Montenbruck::Ephemeris::Pert qw/pert/;
  2         4  
  2         77  
9 2     2   9 use Astro::Montenbruck::MathUtils qw /frac ARCS/;
  2         3  
  2         83  
10 2     2   11 use Astro::Montenbruck::Ephemeris::Planet qw/$NE/;
  2         6  
  2         1409  
11              
12             our $VERSION = 0.02;
13              
14             sub new {
15 4     4 1 9 my $class = shift;
16 4         17 $class->SUPER::new( id => $NE );
17             }
18              
19             sub heliocentric {
20 4     4 1 9 my ( $self, $t ) = @_;
21              
22             # Mean anomalies of planets in [rad]
23 4         12 my $m5 = pi2 * frac( 0.0563867 + 8.4298907 * $t );
24 4         9 my $m6 = pi2 * frac( 0.8825086 + 3.3957748 * $t );
25 4         9 my $m7 = pi2 * frac( 0.3965358 + 1.1902851 * $t );
26 4         8 my $m8 = pi2 * frac( 0.7214906 + 0.6068526 * $t );
27              
28 4         8 my ( $dl, $dr, $db ) = ( 0, 0, 0 ); # Corrections in longitude ["],
29             my $pert_cb = sub {
30 140     140   174 $dl += $_[0];
31 140         158 $dr += $_[1];
32 140         191 $db += $_[2]
33 4         16 };
34              
35             # Perturbations by Jupiter
36 4         12 my $term = pert(
37             T => $t,
38             M => $m8,
39             m => $m5,
40             I_min => 0,
41             I_max => 2,
42             i_min => -2,
43             i_max => 0,
44             callback => $pert_cb
45             );
46              
47 4         15 $term->( 0, -1, 0, 0.1, 0.1, -3.0, 1.8, -0.3, -0.3 );
48 4         13 $term->( 1, 0, 0, 0.0, 0.0, -15.9, 9.0, 0.0, 0.0 );
49 4         11 $term->( 1, -1, 0, -17.6, -29.3, 416.1, -250.0, 0.0, 0.0 );
50 4         40 $term->( 1, -2, 0, -0.4, -0.7, 10.4, -6.2, 0.0, 0.0 );
51 4         12 $term->( 2, -1, 0, -0.2, -0.4, 2.4, -1.4, 0.4, -0.3 );
52              
53             # Perturbations by Saturn
54 4         12 $term = pert(
55             T => $t,
56             M => $m8,
57             m => $m6,
58             I_min => 0,
59             I_max => 2,
60             i_min => -2,
61             i_max => 0,
62             callback => $pert_cb
63             );
64              
65 4         15 $term->( 0, -1, 0, -0.1, 0.0, 0.2, -1.8, -0.1, -0.5 );
66 4         17 $term->( 1, 0, 0, 0.0, 0.0, -8.3, -10.4, 0.0, 0.0 );
67 4         10 $term->( 1, -1, 0, 13.6, -12.7, 187.5, 201.1, 0.0, 0.0 );
68 4         10 $term->( 1, -2, 0, 0.4, -0.4, 4.5, 4.5, 0.0, 0.0 );
69 4         11 $term->( 2, -1, 0, 0.4, -0.1, 1.7, -3.2, 0.2, 0.2 );
70 4         16 $term->( 2, -2, 0, -0.1, 0.0, -0.2, 2.7, 0.0, 0.0 );
71              
72             # Perturbations by Uranus
73 4         11 $term = pert(
74             T => $t,
75             M => $m8,
76             m => $m7,
77             I_min => 1,
78             I_max => 6,
79             i_min => -6,
80             i_max => 0,
81             callback => $pert_cb
82             );
83 4         16 $term->( 1, 0, 0, 32.3, 3549.5, -25880.2, 235.8, -6360.5, 374.0 );
84 4         16 $term->( 1, 0, 1, 31.2, 34.4, -251.4, 227.4, 34.9, 29.3 );
85 4         12 $term->( 1, 0, 2, -1.4, 3.9, -28.6, -10.1, 0.0, -0.9 );
86 4         13 $term->( 2, 0, 0, 6.1, 68.0, -111.4, 2.0, -54.7, 3.7 );
87 4         13 $term->( 2, 0, 1, 0.8, -0.2, -2.1, 2.0, -0.2, 0.8 );
88 4         10 $term->( 3, 0, 0, 0.1, 1.0, -0.7, 0.0, -0.8, 0.1 );
89 4         10 $term->( 0, -1, 0, -0.1, -0.3, -3.6, 0.0, 0.0, 0.0 );
90 4         12 $term->( 1, 0, 0, 0.0, 0.0, 5.5, -6.9, 0.1, 0.0 );
91 4         12 $term->( 1, -1, 0, -2.2, -1.6, -116.3, 163.6, 0.0, -0.1 );
92 4         12 $term->( 1, -2, 0, 0.2, 0.1, -1.2, 0.4, 0.0, -0.1 );
93 4         51 $term->( 2, -1, 0, 4.2, -1.1, -4.4, -34.6, -0.2, 0.1 );
94 4         10 $term->( 2, -2, 0, 8.6, -2.9, -33.4, -97.0, 0.2, 0.1 );
95 4         13 $term->( 3, -1, 0, 0.1, -0.2, 2.1, -1.2, 0.0, 0.1 );
96 4         13 $term->( 3, -2, 0, -4.6, 9.3, 38.2, 19.8, 0.1, 0.1 );
97 4         12 $term->( 3, -3, 0, -0.5, 1.7, 23.5, 7.0, 0.0, 0.0 );
98 4         12 $term->( 4, -2, 0, 0.2, 0.8, 3.3, -1.5, -0.2, -0.1 );
99 4         10 $term->( 4, -3, 0, 0.9, 1.7, 17.9, -9.1, -0.1, 0.0 );
100 4         10 $term->( 4, -4, 0, -0.4, -0.4, -6.2, 4.8, 0.0, 0.0 );
101 4         21 $term->( 5, -3, 0, -1.6, -0.5, -2.2, 7.0, 0.0, 0.0 );
102 4         12 $term->( 5, -4, 0, -0.4, -0.1, -0.7, 5.5, 0.0, 0.0 );
103 4         24 $term->( 5, -5, 0, 0.2, 0.0, 0.0, -3.5, 0.0, 0.0 );
104 4         40 $term->( 6, -4, 0, -0.3, 0.2, 2.1, 2.7, 0.0, 0.0 );
105 4         9 $term->( 6, -5, 0, 0.1, -0.1, -1.4, -1.4, 0.0, 0.0 );
106 4         11 $term->( 6, -6, 0, -0.1, 0.1, 1.4, 0.7, 0.0, 0.0 );
107              
108             # Ecliptic coordinates ([rad],[AU])
109 4         14 my $l =
110             pi2 *
111             frac( 0.1254046 + $m8 / pi2 +
112             ( ( 4982.8 - 21.3 * $t ) * $t + $dl ) / 1296.0e3 );
113 4         9 my $r = 30.072984 + ( 0.001234 + 0.000003 * $t ) * $t + $dr * 1.0e-5;
114 4         10 my $b = ( 54.77 + ( 0.26 + 0.06 * $t ) * $t + $db ) / ARCS;
115              
116 4         30 $l, $b, $r;
117              
118             }
119              
120             # Intermediate variables for calculating geocentric positions.
121             sub _lbr_geo {
122 4     4   7 my ( $self, $t ) = @_;
123              
124 4         11 my $m = pi2 * frac( 0.7214906 + 0.6068526 * $t );
125 4         8 my $dl = 1.04 + 0.02 * cos($m);
126 4         6 my $dr = 0.27 * sin($m);
127 4         7 my $db = 0.03 * sin($m);
128              
129 4         10 $dl, $db, $dr;
130             }
131              
132             1;
133              
134             __END__
135              
136             =pod
137              
138             =encoding UTF-8
139              
140             =head1 NAME
141              
142             Astro::Montenbruck::Ephemeris::Planet::Neptune - Neptune.
143              
144             =head1 SYNOPSIS
145              
146             use Astro::Montenbruck::Ephemeris::Planet::Neptune;
147             my $planet = Astro::Montenbruck::Ephemeris::Planet::Neptune->new();
148             my @geo = $planet->position($t); # apparent geocentric ecliptical coordinates
149              
150             =head1 DESCRIPTION
151              
152             Child class of L<Astro::Montenbruck::Ephemeris::Planet>, responsible for calculating
153             B<Neptune> position.
154              
155             =head1 METHODS
156              
157             =head2 Astro::Montenbruck::Ephemeris::Planet::Neptune->new
158              
159             Constructor.
160              
161             =head2 $self->heliocentric($t)
162              
163             See description in L<Astro::Montenbruck::Ephemeris::Planet>.
164              
165             =head1 AUTHOR
166              
167             Sergey Krushinsky, C<< <krushi at cpan.org> >>
168              
169             =head1 COPYRIGHT AND LICENSE
170              
171             Copyright (C) 2009-2022 by Sergey Krushinsky
172              
173             This library is free software; you can redistribute it and/or modify
174             it under the same terms as Perl itself.
175              
176             =cut