line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::Derivate::PointOnCircle; |
2
|
1
|
|
|
1
|
|
2341
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
extends 'Math::Geometry::Construction::Derivate'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use 5.008008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Math::Geometry::Construction::Types qw(Circle); |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
C<Math::Geometry::Construction::Derivate::PointOnCircle> - point on a Circle |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.024 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.024'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
########################################################################### |
24
|
|
|
|
|
|
|
# # |
25
|
|
|
|
|
|
|
# Accessors # |
26
|
|
|
|
|
|
|
# # |
27
|
|
|
|
|
|
|
########################################################################### |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
with 'Math::Geometry::Construction::Role::AlternativeSources'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'input' => (isa => Circle, |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
required => 1); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my %alternative_sources = |
37
|
|
|
|
|
|
|
(position_sources => {'distance' => {isa => 'Num'}, |
38
|
|
|
|
|
|
|
'quantile' => {isa => 'Num'}, |
39
|
|
|
|
|
|
|
'phi' => {isa => 'Num'}}); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
while(my ($name, $alternatives) = each %alternative_sources) { |
42
|
|
|
|
|
|
|
__PACKAGE__->alternatives |
43
|
|
|
|
|
|
|
(name => $name, |
44
|
|
|
|
|
|
|
alternatives => $alternatives, |
45
|
|
|
|
|
|
|
clear_buffer => 1); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub BUILD { |
49
|
|
|
|
|
|
|
my ($self, $args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->_check_position_sources; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
########################################################################### |
55
|
|
|
|
|
|
|
# # |
56
|
|
|
|
|
|
|
# Retrieve Data # |
57
|
|
|
|
|
|
|
# # |
58
|
|
|
|
|
|
|
########################################################################### |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub calculate_positions { |
61
|
|
|
|
|
|
|
my ($self) = @_; |
62
|
|
|
|
|
|
|
my $circle = $self->input; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $center_p = $circle->center->position; |
65
|
|
|
|
|
|
|
my $support_p = $circle->support->position; |
66
|
|
|
|
|
|
|
return if(!defined($center_p) or !defined($support_p)); |
67
|
|
|
|
|
|
|
my $radius_v = $support_p - $center_p; |
68
|
|
|
|
|
|
|
my $radius = abs($radius_v); |
69
|
|
|
|
|
|
|
return $center_p if($radius == 0); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $phi = atan2($radius_v->[1], $radius_v->[0]); |
72
|
|
|
|
|
|
|
if($self->_has_distance) { |
73
|
|
|
|
|
|
|
$phi += $self->_distance / $radius; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif($self->_has_quantile) { |
76
|
|
|
|
|
|
|
$phi += 6.28318530717959 * $self->_quantile; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif($self->_has_phi) { |
79
|
|
|
|
|
|
|
$phi += $self->_phi; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else { |
82
|
|
|
|
|
|
|
croak "No way to determine position of PointOnCircle ".$self->id; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return($center_p + [$radius * cos($phi), $radius * sin($phi)]); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
########################################################################### |
89
|
|
|
|
|
|
|
# # |
90
|
|
|
|
|
|
|
# Change Data # |
91
|
|
|
|
|
|
|
# # |
92
|
|
|
|
|
|
|
########################################################################### |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub register_derived_point { |
95
|
|
|
|
|
|
|
my ($self, $point) = @_; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$self->input->register_point($point); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=pod |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 INTERFACE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 Public Attributes |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 Methods for Users |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 Methods for Subclass Developers |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright 2013 Lutz Gehlen. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
132
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
133
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|