| 1 | package Geometry::Primitive::Arc; | ||
| 2 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use MooseX::Storage; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 2 | with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); | |
| 6 | |||
| 7 | 2 | ▶ | use Geometry::Primitive::Point; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | has 'angle_start' => ( | |
| 10 | is => 'rw', | ||
| 11 | isa => 'Num', | ||
| 12 | required => 1 | ||
| 13 | ); | ||
| 14 | 2 | has 'angle_end' => ( | |
| 15 | is => 'rw', | ||
| 16 | isa => 'Num', | ||
| 17 | required => 1 | ||
| 18 | ); | ||
| 19 | 2 | has 'origin' => ( | |
| 20 | is => 'rw', | ||
| 21 | isa => 'Geometry::Primitive::Point', | ||
| 22 | coerce => 1 | ||
| 23 | ); | ||
| 24 | 2 | 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 | 3 | ▶ | sub get_point_at_angle { |
|
Subroutine
get_point_at_angle: called CC=1 SCAR=0.0
Pod
documented
| |||
| 39 | 3 | my ($self, $angle) = @_; | |
| 40 | |||
| 41 | 3 | 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 | 1 | ▶ | sub length { |
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||
| 48 | 1 | my ($self) = @_; | |
| 49 | |||
| 50 | 1 | return $self->radius * ($self->angle_end - $self->angle_start); | |
| 51 | } | ||
| 52 | |||
| 53 | 1 | ▶ | sub point_end { |
|
Subroutine
point_end: called CC=1 SCAR=0.0
Pod
documented
| |||
| 54 | 1 | my ($self) = @_; | |
| 55 | |||
| 56 | 1 | return $self->get_point_at_angle($self->angle_end); | |
| 57 | } | ||
| 58 | |||
| 59 | 1 | ▶ | sub point_start { |
|
Subroutine
point_start: called CC=1 SCAR=0.0
Pod
documented
| |||
| 60 | 1 | my ($self) = @_; | |
| 61 | |||
| 62 | 1 | return $self->get_point_at_angle($self->angle_start); | |
| 63 | } | ||
| 64 | |||
| 65 | 0 | ▶ | sub scale { |
|
Subroutine
scale: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 66 | 0 | my ($self, $amount) = @_; | |
| 67 | |||
| 68 | 0 | $self->radius($self->radius * $amount); | |
| 69 | } | ||
| 70 | |||
| 71 | 2 | __PACKAGE__->meta->make_immutable; | |
| 72 | |||
| 73 | 2 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 74 | 2 | 1; | |
| 75 | |||
| 76 | __END__ | ||