line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Montenbruck::CoCo; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
133639
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
4
|
use Exporter qw/import/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
5
|
use POSIX qw /tan atan2 asin acos/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
1621
|
use Astro::Montenbruck::MathUtils qw/reduce_rad/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
8
|
1
|
|
|
1
|
|
6
|
use Math::Trig qw/:pi deg2rad rad2deg/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
89
|
|
9
|
1
|
|
|
1
|
|
408
|
use Readonly; |
|
1
|
|
|
|
|
3109
|
|
|
1
|
|
|
|
|
459
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Scalar our $ECL => 1; |
12
|
|
|
|
|
|
|
Readonly::Scalar our $EQU => 2; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
all => [ qw/ecl2equ equ2ecl equ2hor hor2equ/ ], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }, qw/$ECL $EQU/ ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = 0.01; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Common routine for coordinate conversion |
23
|
|
|
|
|
|
|
# $target = $ECL (1) for equator -> ecliptic |
24
|
|
|
|
|
|
|
# $target = $EQU (2) for ecliptic -> equator |
25
|
|
|
|
|
|
|
sub _equecl { |
26
|
2
|
|
|
2
|
|
23
|
my ( $x, $y, $e, $target ) = @_; |
27
|
2
|
50
|
|
|
|
8
|
my $k = $target == $ECL ? 1 |
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
: $target == $EQU ? -1 : 0; |
29
|
2
|
|
|
|
|
6
|
die "Unknown target: '$target'! \n" until $k; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
23
|
my $sin_a = sin($x); |
32
|
2
|
|
|
|
|
9
|
my $cos_e = cos($e); |
33
|
2
|
|
|
|
|
4
|
my $sin_e = sin($e); |
34
|
2
|
|
|
|
|
39
|
reduce_rad(atan2( $sin_a * $cos_e + $k * ( tan($y) * $sin_e ), cos($x) )), |
35
|
|
|
|
|
|
|
asin( sin($y) * $cos_e - $k * ( cos($y) * $sin_e * $sin_a ) ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub equ2ecl { |
40
|
1
|
|
|
1
|
1
|
3501
|
map { rad2deg $_ } _equecl( ( map { deg2rad $_ } @_ ), $ECL ); |
|
2
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
27
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub ecl2equ { |
44
|
1
|
|
|
1
|
1
|
3623
|
map { rad2deg $_ } _equecl( ( map { deg2rad $_ } @_ ), $EQU ); |
|
2
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
19
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Converts between azimuth/altitude and hour-angle/declination. |
49
|
|
|
|
|
|
|
# The equations are symmetrical in the two pairs of coordinates so that exactly |
50
|
|
|
|
|
|
|
# the same code may be used to convert in either direction, there is no need |
51
|
|
|
|
|
|
|
# to specify direction with a swich. |
52
|
|
|
|
|
|
|
sub _equhor { |
53
|
2
|
|
|
2
|
|
16
|
my ($x, $y, $phi) = @_; |
54
|
2
|
|
|
|
|
3
|
my ($sx, $sy, $sphi) = map{ sin } ($x, $y, $phi); |
|
6
|
|
|
|
|
13
|
|
55
|
2
|
|
|
|
|
4
|
my ($cx, $cy, $cphi) = map{ cos } ($x, $y, $phi); |
|
6
|
|
|
|
|
11
|
|
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
5
|
my $sq = ($sy * $sphi) + ($cy * $cphi * $cx); |
58
|
2
|
|
|
|
|
6
|
my $q = asin($sq); |
59
|
2
|
|
|
|
|
5
|
my $cp = ($sy - ($sphi * $sq)) / ($cphi * cos($q)); |
60
|
2
|
|
|
|
|
7
|
my $p = acos($cp); |
61
|
2
|
100
|
|
|
|
6
|
if ($sx > 0) { |
62
|
1
|
|
|
|
|
2
|
$p = pi2 - $p; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
5
|
($p, $q) |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub equ2hor { |
68
|
2
|
|
|
2
|
1
|
6166
|
map {rad2deg $_} _equhor( map { deg2rad $_ } @_ ) |
|
4
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
34
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub hor2equ { |
72
|
1
|
|
|
1
|
1
|
3350
|
equ2hor(@_) |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Astro::Montenbruck::CoCo - Coordinates conversions. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Version 0.01 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Celestial sphera related calculations used by AstroScript modules. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 EXPORT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * L</equ2ecl($alpha, $delta, $epsilon)> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * L</ecl2equ($lambda, $beta, $epsilon)> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 FUNCTIONS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 equ2ecl($alpha, $delta, $epsilon) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Conversion of equatorial into ecliptic coordinates |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head3 Arguments |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * B<$alpha> â right ascension |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * B<$delta> â declination |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * B<$epsilon> â ecliptic obliquity |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head3 Returns |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Ecliptic coordinates: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * B<$lambda> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * B<$beta> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
All arguments and return values are in degrees. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 ecl2equ($lambda, $beta, $epsilon) |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Conversion of ecliptic into equatorial coordinates |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head3 Arguments |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * B<$lambda> â celestial longitude |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * B<$beta> â celestial latitude |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * B<$epsilon> â ecliptic obliquity |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head3 Returns |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Equatorial coordinates: |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * B<$alpha> â right ascension |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * B<$delta> â declination |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
All arguments and return values are in degrees. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 equ2hor($h, $delta, $phi) |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Conversion of equatorial into horizontal coordinates |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head3 Arguments |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
B<$h> â the local hour angle, in degrees, measured westwards from the South. |
180
|
|
|
|
|
|
|
C<h = Local Sidereal Time - Right Ascension> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
B<$delta> â declination, in arc-degrees |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
B<$phi> â the observer's latitude, in arc-degrees, positive in the nothern |
189
|
|
|
|
|
|
|
hemisphere, negative in the southern hemisphere. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head3 Returns |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Horizontal coordinates: |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=over |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * B<azimuth>, in degrees, measured westward from the South |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * B<altitude>, in degrees, positive above the horizon |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=back |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 hor2equ($az, $alt, $phi) |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Convert horizontal to equatorial coordinates. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head3 Arguments |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
B<$az> â azimuth, in degrees, measured westward from the South |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
B<$alt> â altitude, in degrees, positive above the horizon |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
B<$phi> â the observer's latitude, in arc-degrees, positive in the nothern |
224
|
|
|
|
|
|
|
hemisphere, negative in the southern hemisphere. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=back |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head3 Returns |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Horizontal coordinates: |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item * hour angle, in arc-degrees |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * declination, in arc-degrees |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=back |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 SUPPORT |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
perldoc Astro::Montenbruck::CoCo |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 AUTHOR |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Sergey Krushinsky, C<< <krushi at cpan.org> >> |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Copyright (C) 2009-2019 by Sergey Krushinsky |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
256
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |