Construction/Derivate/IntersectionCircleLine.pm

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 89.5% 43 / 48 CC 6 SCAR 11.1
CC
6
Cov
92%
calculate_positions
5.1
register_derived_point
2.0
BEGIN
1.0
CRAP 3.0
« Construction/Role/PositionSelection.pm ↑ Summary Construction.pm »
1 package Math::Geometry::Construction::Derivate::IntersectionCircleLine;
2 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 extends 'Math::Geometry::Construction::Derivate';
4  
5 5 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Math::Geometry::Construction::Types qw(CircleLine);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 C<Math::Geometry::Construction::Derivate::IntersectionCircleLine> - circle line intersection
13  
14 =head1 VERSION
15  
16 Version 0.024
17  
18 =cut
19  
20 5 our $VERSION = '0.024';
21  
22  
23 ###########################################################################
24 # #
25 # Accessors #
26 # #
27 ###########################################################################
28  
29 5 has 'input' => (isa => CircleLine,
30 coerce => 1,
31 is => 'bare',
32 traits => ['Array'],
33 required => 1,
34 handles => {count_input => 'count',
35 input => 'elements',
36 single_input => 'accessor'});
37  
38 ###########################################################################
39 # #
40 # Retrieve Data #
41 # #
42 ###########################################################################
43  
44 20 ▶sub calculate_positions {
Subroutine calculate_positions: called CC=5 SCAR=16.2
Pod undocumented
45 20 my ($self) = @_;
46 20 my ($circle, $line) = $self->input;
47  
48 20 my $c_center_p = $circle->center->position;
49 20 my $c_radius = $circle->radius;
50 20 my @l_support_p = map { $_->position } $line->support;
51  
52 20 foreach($c_center_p, $c_radius, @l_support_p) {
53 80 ▶ return if(!defined($_));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 80 80
54 }
55  
56 20 ▶ my $l_parallel = $line->parallel or return;
Branch: 1 branch
BranchTrueFalseTotal
my $l_parallel = $line->parallel or return 20 0 20
57 20 my $l_normal = $line->normal;
58 20 my $l_constant = $l_normal * $l_support_p[0];
59  
60 20 my $a = $l_normal * $c_center_p - $l_constant;
61 20 my $rad = $c_radius ** 2 - $a ** 2;
62 20 ▶ return if($rad < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $rad < 0 0 20 20
63 20 my $b = sqrt($rad);
64
65 20 return($c_center_p - $l_normal * $a - $l_parallel * $b,
66 $c_center_p - $l_normal * $a + $l_parallel * $b);
67 }
68  
69 ###########################################################################
70 # #
71 # Change Data #
72 # #
73 ###########################################################################
74  
75 40 ▶sub register_derived_point {
Subroutine register_derived_point: called CC=2 SCAR=6.9
Pod undocumented
76 40 my ($self, $point) = @_;
77  
78 40 foreach($self->input) { $_->register_point($point) }
79 }
80  
81 5 1;
82  
83  
84 __END__
« Construction/Role/PositionSelection.pm ↑ Summary Construction.pm »