line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::Derivate::PointOnLine; |
2
|
1
|
|
|
1
|
|
2435
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
extends 'Math::Geometry::Construction::Derivate'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use 5.008008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Math::Geometry::Construction::Types qw(Line); |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
C<Math::Geometry::Construction::Derivate::PointOnLine> - point on a line |
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 => Line, |
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
|
|
|
|
|
|
|
'x' => {isa => 'Num'}, |
40
|
|
|
|
|
|
|
'y' => {isa => 'Num'}}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
while(my ($name, $alternatives) = each %alternative_sources) { |
43
|
|
|
|
|
|
|
__PACKAGE__->alternatives |
44
|
|
|
|
|
|
|
(name => $name, |
45
|
|
|
|
|
|
|
alternatives => $alternatives, |
46
|
|
|
|
|
|
|
clear_buffer => 1); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub BUILD { |
50
|
|
|
|
|
|
|
my ($self, $args) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$self->_check_position_sources; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
########################################################################### |
56
|
|
|
|
|
|
|
# # |
57
|
|
|
|
|
|
|
# Retrieve Data # |
58
|
|
|
|
|
|
|
# # |
59
|
|
|
|
|
|
|
########################################################################### |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub calculate_positions { |
62
|
|
|
|
|
|
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
my $line = $self->input; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my @support_p = map { $_->position } $line->support; |
66
|
|
|
|
|
|
|
return if(!defined($support_p[0]) or !defined($support_p[1])); |
67
|
|
|
|
|
|
|
my $s_distance = ($support_p[1] - $support_p[0]); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if($self->_has_distance) { |
70
|
|
|
|
|
|
|
my $d = abs($s_distance); |
71
|
|
|
|
|
|
|
return if($d == 0); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return($support_p[0] + $s_distance / $d * $self->_distance); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif($self->_has_quantile) { |
76
|
|
|
|
|
|
|
return($support_p[0] + $s_distance * $self->_quantile); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif($self->_has_x) { |
79
|
|
|
|
|
|
|
my $sx = $s_distance->[0]; |
80
|
|
|
|
|
|
|
return if($sx == 0); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $scale = ($self->_x - $support_p[0]->[0]) / $sx; |
83
|
|
|
|
|
|
|
return($support_p[0] + $s_distance * $scale); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif($self->_has_y) { |
86
|
|
|
|
|
|
|
my $sy = $s_distance->[1]; |
87
|
|
|
|
|
|
|
return if($sy == 0); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $scale = ($self->_y - $support_p[0]->[1]) / $sy; |
90
|
|
|
|
|
|
|
return($support_p[0] + $s_distance * $scale); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { |
93
|
|
|
|
|
|
|
croak "No way to determine position of PointOnLine ".$self->id; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
########################################################################### |
98
|
|
|
|
|
|
|
# # |
99
|
|
|
|
|
|
|
# Change Data # |
100
|
|
|
|
|
|
|
# # |
101
|
|
|
|
|
|
|
########################################################################### |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub register_derived_point { |
104
|
|
|
|
|
|
|
my ($self, $point) = @_; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$self->input->register_point($point); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SYNOPSIS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 INTERFACE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 Public Attributes |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 Methods for Users |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 Methods for Subclass Developers |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2011, 2013 Lutz Gehlen. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
141
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
142
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|