line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::Derivate::IntersectionLineLine; |
2
|
1
|
|
|
1
|
|
2221
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
extends 'Math::Geometry::Construction::Derivate'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use 5.008008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Math::Geometry::Construction::Types qw(LineLine); |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
use List::MoreUtils qw(any); |
10
|
|
|
|
|
|
|
use Math::Vector::Real; |
11
|
|
|
|
|
|
|
use Math::MatrixReal; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
C<Math::Geometry::Construction::Derivate::IntersectionLineLine> - line line intersection |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.024 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.024'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
########################################################################### |
27
|
|
|
|
|
|
|
# # |
28
|
|
|
|
|
|
|
# Accessors # |
29
|
|
|
|
|
|
|
# # |
30
|
|
|
|
|
|
|
########################################################################### |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'input' => (isa => LineLine, |
33
|
|
|
|
|
|
|
is => 'bare', |
34
|
|
|
|
|
|
|
traits => ['Array'], |
35
|
|
|
|
|
|
|
required => 1, |
36
|
|
|
|
|
|
|
handles => {count_input => 'count', |
37
|
|
|
|
|
|
|
input => 'elements', |
38
|
|
|
|
|
|
|
single_input => 'accessor'}); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
########################################################################### |
41
|
|
|
|
|
|
|
# # |
42
|
|
|
|
|
|
|
# Retrieve Data # |
43
|
|
|
|
|
|
|
# # |
44
|
|
|
|
|
|
|
########################################################################### |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub calculate_positions { |
47
|
|
|
|
|
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
my @lines = $self->input; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my @normals = (); |
51
|
|
|
|
|
|
|
my @constants = (); |
52
|
|
|
|
|
|
|
foreach(@lines) { |
53
|
|
|
|
|
|
|
my @support = $_->support; |
54
|
|
|
|
|
|
|
my @support_positions = map { $_->position } @support; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return undef if(any { !defined($_) } @support_positions); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $this_normal = $_->normal; |
59
|
|
|
|
|
|
|
push(@normals, $this_normal); |
60
|
|
|
|
|
|
|
push(@constants, $this_normal * $support_positions[0]); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $matrix = Math::MatrixReal->new_from_rows([map { [@$_] } @normals]); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return if($matrix->det == 0); # check to prevent carp from inverse |
66
|
|
|
|
|
|
|
my $inverse = $matrix->inverse; |
67
|
|
|
|
|
|
|
return if(!$inverse); # only possible - if at all - for num. reasons |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return V($inverse->element(1, 1) * $constants[0] + |
70
|
|
|
|
|
|
|
$inverse->element(1, 2) * $constants[1], |
71
|
|
|
|
|
|
|
$inverse->element(2, 1) * $constants[0] + |
72
|
|
|
|
|
|
|
$inverse->element(2, 2) * $constants[1]); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
########################################################################### |
76
|
|
|
|
|
|
|
# # |
77
|
|
|
|
|
|
|
# Change Data # |
78
|
|
|
|
|
|
|
# # |
79
|
|
|
|
|
|
|
########################################################################### |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub register_derived_point { |
82
|
|
|
|
|
|
|
my ($self, $point) = @_; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
foreach($self->input) { $_->register_point($point) } |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 INTERFACE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Public Attributes |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 Methods for Users |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 Methods for Subclass Developers |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright 2011, 2013 Lutz Gehlen. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
119
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
120
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|