line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::Montenbruck::CoCo; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
88496
|
use strict; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
106
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
110
|
|
5
|
4
|
|
|
4
|
|
16
|
use Exporter qw/import/; |
|
4
|
|
|
|
|
36
|
|
|
4
|
|
|
|
|
121
|
|
6
|
4
|
|
|
4
|
|
19
|
use POSIX qw /tan atan2 asin acos/; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
22
|
|
7
|
4
|
|
|
4
|
|
2067
|
use Astro::Montenbruck::MathUtils qw/reduce_rad/; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
208
|
|
8
|
4
|
|
|
4
|
|
23
|
use Math::Trig qw/:pi deg2rad rad2deg/; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
460
|
|
9
|
4
|
|
|
4
|
|
446
|
use Readonly; |
|
4
|
|
|
|
|
3284
|
|
|
4
|
|
|
|
|
2135
|
|
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 ecl2equ_rect equ2ecl_rect/ ], |
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
|
676
|
|
|
676
|
|
5016
|
my ( $x, $y, $e, $target ) = @_; |
27
|
676
|
50
|
|
|
|
1977
|
my $k = $target == $ECL ? 1 |
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
: $target == $EQU ? -1 : 0; |
29
|
676
|
|
|
|
|
1639
|
die "Unknown target: '$target'! \n" until $k; |
30
|
|
|
|
|
|
|
|
31
|
676
|
|
|
|
|
1671
|
my $sin_a = sin($x); |
32
|
676
|
|
|
|
|
1153
|
my $cos_e = cos($e); |
33
|
676
|
|
|
|
|
1002
|
my $sin_e = sin($e); |
34
|
676
|
|
|
|
|
14583
|
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
|
4199
|
map { rad2deg $_ } _equecl( ( map { deg2rad $_ } @_ ), $ECL ); |
|
2
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
28
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub ecl2equ { |
44
|
675
|
|
|
675
|
1
|
16757
|
map { rad2deg $_ } _equecl( ( map { deg2rad $_ } @_ ), $EQU ); |
|
1350
|
|
|
|
|
5849
|
|
|
2025
|
|
|
|
|
10402
|
|
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
|
|
15
|
my ($x, $y, $phi) = @_; |
54
|
2
|
|
|
|
|
4
|
my ($sx, $sy, $sphi) = map{ sin } ($x, $y, $phi); |
|
6
|
|
|
|
|
13
|
|
55
|
2
|
|
|
|
|
5
|
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
|
|
|
|
|
1
|
$p = pi2 - $p; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
5
|
($p, $q) |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub equ2hor { |
68
|
2
|
|
|
2
|
1
|
6927
|
map {rad2deg $_} _equhor( map { deg2rad $_ } @_ ) |
|
4
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
35
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub hor2equ { |
72
|
1
|
|
|
1
|
1
|
3785
|
equ2hor(@_) |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Astro::Montenbruck::CoCo - Coordinates conversions. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Version 0.01 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Celestial sphera related calculations used by Astro::Montenbruck modules. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 EXPORT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * L</equ2ecl($alpha, $delta, $epsilon)> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * L</ecl2equ($lambda, $beta, $epsilon)> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 FUNCTIONS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 equ2ecl($alpha, $delta, $epsilon) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Conversion of equatorial into ecliptic coordinates |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head3 Arguments |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * B<$alpha> — right ascension |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * B<$delta> — declination |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * B<$epsilon> — ecliptic obliquity |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head3 Returns |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Ecliptic coordinates: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * B<$lambda> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * B<$beta> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
All arguments and return values are in degrees. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 ecl2equ($lambda, $beta, $epsilon) |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Conversion of ecliptic into equatorial coordinates |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head3 Arguments |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=over |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * B<$lambda> — celestial longitude |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * B<$beta> — celestial latitude |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * B<$epsilon> — ecliptic obliquity |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head3 Returns |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Equatorial coordinates: |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * B<$alpha> — right ascension |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * B<$delta> — declination |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
All arguments and return values are in degrees. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 equ2hor($h, $delta, $phi) |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Conversion of equatorial into horizontal coordinates |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head3 Arguments |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
B<$h> — the local hour angle, in degrees, measured westwards from the South. |
181
|
|
|
|
|
|
|
C<h = Local Sidereal Time - Right Ascension> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
B<$delta> — declination, in arc-degrees |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
B<$phi> — the observer's latitude, in arc-degrees, positive in the nothern |
190
|
|
|
|
|
|
|
hemisphere, negative in the southern hemisphere. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=back |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head3 Returns |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Horizontal coordinates: |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=over |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item * B<azimuth>, in degrees, measured westward from the South |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * B<altitude>, in degrees, positive above the horizon |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=back |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 hor2equ($az, $alt, $phi) |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Convert horizontal to equatorial coordinates. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head3 Arguments |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=over |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
B<$az> — azimuth, in degrees, measured westward from the South |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
B<$alt> — altitude, in degrees, positive above the horizon |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
B<$phi> — the observer's latitude, in arc-degrees, positive in the nothern |
225
|
|
|
|
|
|
|
hemisphere, negative in the southern hemisphere. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=back |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head3 Returns |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Horizontal coordinates: |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=over |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * hour angle, in arc-degrees |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * declination, in arc-degrees |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 SUPPORT |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
perldoc Astro::Montenbruck::CoCo |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 AUTHOR |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Sergey Krushinsky, C<< <krushi at cpan.org> >> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Copyright (C) 2009-2022 by Sergey Krushinsky |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
257
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=cut |