line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geometry::Primitive::Arc; |
2
|
1
|
|
|
1
|
|
53049
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use MooseX::Storage; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Geometry::Primitive::Point; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'angle_start' => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => 'Num', |
12
|
|
|
|
|
|
|
required => 1 |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
has 'angle_end' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Num', |
17
|
|
|
|
|
|
|
required => 1 |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
has 'origin' => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
22
|
|
|
|
|
|
|
coerce => 1 |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
has 'radius' => ( |
25
|
|
|
|
|
|
|
is => 'rw', |
26
|
|
|
|
|
|
|
isa => 'Num', |
27
|
|
|
|
|
|
|
required => 1 |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Area of a sector, if it's ever needed... |
31
|
|
|
|
|
|
|
# sub area { |
32
|
|
|
|
|
|
|
# my ($self) = @_; |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# return (($self->radius**2 * ($self->angle_end - $self->angle_start)) / 2 |
35
|
|
|
|
|
|
|
# ); |
36
|
|
|
|
|
|
|
# } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_point_at_angle { |
39
|
|
|
|
|
|
|
my ($self, $angle) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return Geometry::Primitive::Point->new( |
42
|
|
|
|
|
|
|
x => $self->origin->x + ($self->radius * cos($angle)), |
43
|
|
|
|
|
|
|
y => $self->origin->y + ($self->radius * sin($angle)) |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub length { |
48
|
|
|
|
|
|
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self->radius * ($self->angle_end - $self->angle_start); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub point_end { |
54
|
|
|
|
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return $self->get_point_at_angle($self->angle_end); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub point_start { |
60
|
|
|
|
|
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $self->get_point_at_angle($self->angle_start); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub scale { |
66
|
|
|
|
|
|
|
my ($self, $amount) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$self->radius($self->radius * $amount); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
no Moose; |
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Geometry::Primitive::Arc - Portion of the circumference of a Circle |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Geometry::Primitive::Arc represents a closed segment of a curve. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use Geometry::Primitive::Arc; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $arc = Geometry::Primitive::Arc->new( |
91
|
|
|
|
|
|
|
angle_start => 0, |
92
|
|
|
|
|
|
|
angle_end => 1.57079633, |
93
|
|
|
|
|
|
|
radius => 15 |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 angle_start |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The starting angle for this arc in radians. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 angle_end |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The ending angle for this arc in radians. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 radius |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns the radius of the arc. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 origin |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Set/Get the origin of this arc. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 new |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Creates a new Geometry::Primitive::Arc |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 get_point_at_angle |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Given angle in radians returns the point at that angle on this arc. Returns |
123
|
|
|
|
|
|
|
undef if the angle falls outside this arc's range. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 length |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns the length of this arc. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 point_end |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Get the end point. Provided for Shape role. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 point_start |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Get the start point. Provided for Shape role. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 scale ($amount) |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Increases the radius by multiplying it by the supplied amount. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Cory Watson <gphat@cpan.org> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
You can redistribute and/or modify this code under the same terms as Perl |
148
|
|
|
|
|
|
|
itself. |