| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::Coords::Angle::Hour; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Astro::Coords::Angle::Hour - Representation of an angle in units of hours |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Astro::Coords::Angle::Hour; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$ha = new Astro::Coords::Angle::Hour( "12h30m22.4s", units => 'sex'); |
|
12
|
|
|
|
|
|
|
$ha = new Astro::Coords::Angle::Hour( 12.53, units => 'hour); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$ha = new Astro::Coords::Angle::Hour( 12.53 ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Class similar to C<Astro::Coords::Angle> but representing the angle |
|
19
|
|
|
|
|
|
|
as a time. Suitable for use as hour angle or Right Ascension. |
|
20
|
|
|
|
|
|
|
Inherits from C<Astro::Coords::Angle>. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
For hour angle a range of "PI" is suitable, for Right Ascension use "2PI". |
|
23
|
|
|
|
|
|
|
Default range is none at all. If no units are provided, the units will be |
|
24
|
|
|
|
|
|
|
guessed using the same scheme as for C<Astro::Coords::Angle> except that |
|
25
|
|
|
|
|
|
|
values greater than 2PI will be assumed to be decimal hours. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
21
|
|
|
21
|
|
14984257
|
use 5.006; |
|
|
21
|
|
|
|
|
81
|
|
|
31
|
21
|
|
|
21
|
|
126
|
use strict; |
|
|
21
|
|
|
|
|
52
|
|
|
|
21
|
|
|
|
|
550
|
|
|
32
|
21
|
|
|
21
|
|
167
|
use warnings; |
|
|
21
|
|
|
|
|
42
|
|
|
|
21
|
|
|
|
|
718
|
|
|
33
|
21
|
|
|
21
|
|
139
|
use warnings::register; |
|
|
21
|
|
|
|
|
64
|
|
|
|
21
|
|
|
|
|
2431
|
|
|
34
|
21
|
|
|
21
|
|
184
|
use Carp; |
|
|
21
|
|
|
|
|
43
|
|
|
|
21
|
|
|
|
|
1463
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
21
|
|
|
21
|
|
650
|
use Astro::PAL; |
|
|
21
|
|
|
|
|
4081
|
|
|
|
21
|
|
|
|
|
8764
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
21
|
|
|
21
|
|
159
|
use base qw/ Astro::Coords::Angle /; |
|
|
21
|
|
|
|
|
51
|
|
|
|
21
|
|
|
|
|
3189
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Package Global variables |
|
41
|
21
|
|
|
21
|
|
152
|
use vars qw/ $VERSION /; |
|
|
21
|
|
|
|
|
48
|
|
|
|
21
|
|
|
|
|
11605
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$VERSION = '0.20'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Accessor Methods |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over 4 |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item B<hours> |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Return the angle in decimal hours. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$deg = $ang->hours; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub hours { |
|
60
|
28
|
|
|
28
|
1
|
63
|
my $self = shift; |
|
61
|
28
|
|
|
|
|
71
|
my $rad = $self->radians; |
|
62
|
28
|
|
|
|
|
134
|
return $rad * Astro::PAL::DR2H; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 General Methods |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item B<in_format> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
As for base class implementation, except that 'hour' (and abbreviation) is a supported |
|
74
|
|
|
|
|
|
|
format. 'sexagesimal' format will result in a stringified form of the object in hours, |
|
75
|
|
|
|
|
|
|
minutes and seconds. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$hr = $hour->in_format( 'hour' ); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub in_format { |
|
82
|
23126
|
|
|
23126
|
1
|
38029
|
my $self = shift; |
|
83
|
23126
|
|
|
|
|
45388
|
my $format = shift; |
|
84
|
23126
|
100
|
|
|
|
46267
|
$format = lc($format) if $format; |
|
85
|
23126
|
100
|
100
|
|
|
54539
|
return $self->hours() if (defined $format && $format =~ /^h/); |
|
86
|
23116
|
|
|
|
|
55390
|
return $self->SUPER::in_format( $format ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Class Methods |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The following methods control the default behaviour of the class. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item B<NDP> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
As for the base class except that the default number of decimal places |
|
100
|
|
|
|
|
|
|
is 3. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This method has no effect on the base class. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
{ |
|
107
|
|
|
|
|
|
|
my $DEFAULT_NDP = 3; |
|
108
|
|
|
|
|
|
|
my $NDP = $DEFAULT_NDP; |
|
109
|
|
|
|
|
|
|
sub NDP { |
|
110
|
32
|
|
|
32
|
1
|
7080
|
my $class = shift; |
|
111
|
32
|
100
|
|
|
|
106
|
if (@_) { |
|
112
|
3
|
|
|
|
|
6
|
my $arg = shift; |
|
113
|
3
|
50
|
|
|
|
12
|
if (defined $arg) { |
|
114
|
3
|
|
|
|
|
8
|
$NDP = $arg; |
|
115
|
|
|
|
|
|
|
} else { |
|
116
|
0
|
|
|
|
|
0
|
$NDP = $DEFAULT_NDP; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
32
|
|
|
|
|
89
|
return $NDP; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item B<DELIM> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
As for the base class. The global value in this class does not have |
|
126
|
|
|
|
|
|
|
any effect on the base class. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
{ |
|
131
|
|
|
|
|
|
|
my $DEFAULT_DELIM = ":"; |
|
132
|
|
|
|
|
|
|
my $DELIM = $DEFAULT_DELIM; |
|
133
|
|
|
|
|
|
|
sub DELIM { |
|
134
|
35
|
|
|
35
|
1
|
98
|
my $class = shift; |
|
135
|
35
|
100
|
|
|
|
90
|
if (@_) { |
|
136
|
2
|
|
|
|
|
4
|
my $arg = shift; |
|
137
|
2
|
50
|
|
|
|
8
|
if (defined $arg) { |
|
138
|
2
|
|
|
|
|
5
|
$DELIM = $arg; |
|
139
|
|
|
|
|
|
|
} else { |
|
140
|
0
|
|
|
|
|
0
|
$DELIM = $DEFAULT_DELIM; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
35
|
|
|
|
|
97
|
return $DELIM; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=begin __PRIVATE_METHODS__ |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 Private Methods |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
These methods are not part of the API and should not be called directly. |
|
156
|
|
|
|
|
|
|
They are documented for completeness. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 4 |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item B<_cvt_torad> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Same as the base class, except that if the units are hours |
|
163
|
|
|
|
|
|
|
or sexagesimal, the resulting number is multiplied by 15 before being |
|
164
|
|
|
|
|
|
|
passed up to the constructor (since 24 hours is equivalent to 360 degrees). |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _cvt_torad { |
|
169
|
33238
|
|
|
33238
|
|
55117
|
my $self = shift; |
|
170
|
33238
|
|
|
|
|
48034
|
my $input = shift; |
|
171
|
33238
|
|
|
|
|
47807
|
my $units = shift; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# If we haven't got any units attempt to guess some |
|
174
|
33238
|
100
|
|
|
|
68343
|
$units = $self->_guess_units( $input ) unless defined $units; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# if units are hours, tell the base class we have degrees |
|
177
|
|
|
|
|
|
|
# $unt is the unit that will be reported to the base class |
|
178
|
|
|
|
|
|
|
# $units is the unit known to the subclass |
|
179
|
33238
|
|
|
|
|
47230
|
my $unt = $units; |
|
180
|
33238
|
100
|
66
|
|
|
125738
|
if (defined $units && $units =~ /^h/) { |
|
181
|
6
|
|
|
|
|
13
|
$unt = 'deg'; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# Do the conversion |
|
185
|
33238
|
|
|
|
|
87982
|
my $rad = $self->SUPER::_cvt_torad( $input, $unt ); |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# scale if we had sexagesimal or hour as units |
|
188
|
33238
|
100
|
66
|
|
|
128857
|
if (defined $rad && $units =~ /^[sh]/) { |
|
189
|
1027
|
|
|
|
|
2025
|
$rad *= 15; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
33238
|
|
|
|
|
76116
|
return $rad; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item B<_guess_units> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Guess the units. Same as base class except that values greater than 2PI |
|
198
|
|
|
|
|
|
|
radians are assumed to be hours rather than degrees. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$guess = $hr->_guess_units( $input ); |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub _guess_units { |
|
205
|
19
|
|
|
19
|
|
34
|
my $self = shift; |
|
206
|
19
|
|
|
|
|
34
|
my $input = shift; |
|
207
|
19
|
|
|
|
|
99
|
my $guess = $self->SUPER::_guess_units( $input ); |
|
208
|
19
|
100
|
|
|
|
75
|
$guess = 'h' if $guess =~ /^d/; |
|
209
|
19
|
|
|
|
|
45
|
return $guess; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item B<_r2f> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Routine to convert angle in radians to a formatted array |
|
215
|
|
|
|
|
|
|
of numbers in order of sign, hour, min, sec, frac. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
@retval = $ang->_r2f( $ndp ); |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Note that the number of decimal places is an argument. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub _r2f { |
|
226
|
36
|
|
|
36
|
|
67
|
my $self = shift; |
|
227
|
36
|
|
|
|
|
56
|
my $res = shift; |
|
228
|
36
|
|
|
|
|
91
|
my ($sign, @dmsf) = Astro::PAL::palDr2tf($res, $self->radians); |
|
229
|
36
|
|
|
|
|
137
|
return ($sign, @dmsf); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=end __PRIVATE_METHODS__ |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 AUTHOR |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Tim Jenness E<lt>t.jenness@cpan.orgE<gt> |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Copyright (C) 2004-2005 Tim Jenness. All Rights Reserved. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
243
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
|
244
|
|
|
|
|
|
|
Foundation; either version 3 of the License, or (at your option) any later |
|
245
|
|
|
|
|
|
|
version. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,but WITHOUT ANY |
|
248
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
249
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
252
|
|
|
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|
253
|
|
|
|
|
|
|
Place,Suite 330, Boston, MA 02111-1307, USA |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
1; |