Construction/Derivate/IntersectionLineLine.pm

filter: Statementstmt 100% 46 / 46 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 92.1% 59 / 64 CC 6 SCAR 9.1
CC
6
Cov
94%
calculate_positions
5.0
register_derived_point
2.0
__ANON__
1.0
CRAP 2.5
« Construction/Role/Input.pm ↑ Summary Construction/Vector.pm »
1 package Math::Geometry::Construction::Derivate::IntersectionLineLine;
2 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 extends 'Math::Geometry::Construction::Derivate';
4  
5 4 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Math::Geometry::Construction::Types qw(LineLine);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Math::Vector::Real;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Math::MatrixReal;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 4 our $VERSION = '0.024';
24  
25  
26 ###########################################################################
27 # #
28 # Accessors #
29 # #
30 ###########################################################################
31  
32 4 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 8 ▶sub calculate_positions {
Subroutine calculate_positions: called CC=5 SCAR=16.2
Pod undocumented
47 8 my ($self) = @_;
48 8 my @lines = $self->input;
49  
50 8 my @normals = ();
51 8 my @constants = ();
52 8 foreach(@lines) {
53 16 my @support = $_->support;
54 16 my @support_positions = map { $_->position } @support;
55  
56 16 ▶ return undef if(any { !defined($_) } @support_positions);
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { not defined $_; } , @support_positions) 0 16 16
57
58 16 my $this_normal = $_->normal;
59 16 push(@normals, $this_normal);
60 16 push(@constants, $this_normal * $support_positions[0]);
61 }
62  
63 8 my $matrix = Math::MatrixReal->new_from_rows([map { [@$_] } @normals]);
64  
65 8 ▶ return if($matrix->det == 0); # check to prevent carp from inverse
Branch: 1 branch
BranchTrueFalseTotal
if $matrix->det == 0 0 8 8
66 8 my $inverse = $matrix->inverse;
67 8 ▶ return if(!$inverse); # only possible - if at all - for num. reasons
Branch: 1 branch
BranchTrueFalseTotal
unless $inverse 0 8 8
68  
69 8 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 13 ▶sub register_derived_point {
Subroutine register_derived_point: called CC=2 SCAR=6.9
Pod undocumented
82 13 my ($self, $point) = @_;
83  
84 13 foreach($self->input) { $_->register_point($point) }
85 }
86  
87 4 1;
88  
89  
90 __END__
« Construction/Role/Input.pm ↑ Summary Construction/Vector.pm »