blib/lib/Math/Intersection/Circle/Line.pm

filter: Statementstmt 99.6% 269 / 270 Branchbran 66.0% 99 / 150 Conditioncond 64.5% 120 / 186 MC/DCmcdc 36.4% 35 / 96 Subroutinesub 100% 80 / 80 Podpod 88.5% 31 / 35 totaltotal 77.6% 634 / 817 CC 142 SCAR 17.5
CC
142
Cov
81%
threeCollinearPoints
14.8
near4
9.4
centroid
9.2
CRAP 5.8
↑ Summary
1 =pod
2  
3 =encoding utf8
4  
5 =head1 Name
6  
7 Math::Intersection::Circle::Line - Find the points at which circles and lines
8 intersect to test geometric intuition.
9  
10 =head1 Synopsis
11  
12 use Math::Intersection::Circle::Line q(:all);
13 use Test::More q(no_plan);
14 use utf8;
15  
16 # Euler Line, see: L<https://en.wikipedia.org/wiki/Euler_line>
17  
18 if (1)
19 {my @t = (0, 0, 4, 0, 0, 3); # Corners of the triangle
20 &areaOfPolygon(sub {ok !$_[0]}, # Polygon formed by these points has zero area and so is a line or a point
21 &circumCircle (sub {@_[0,1]}, @t), # green
22 &ninePointCircle(sub {@_[0,1]}, @t), # red
23 &orthoCentre (sub {@_[0,1]}, @t), # blue
24 &centroid (sub {@_[0,1]}, @t)); # orange
25 }
26  
27 # An isosceles tringle with an apex height of 3/4 of the radius of its
28 # circumcircle divides Euler's line into 6 equal pieces
29  
30 if (1)
31 {my $r = 400; # Arbitrary but convenient radius
32 intersectionCircleLine # Find coordinates of equiangles of isoceles triangle
33 {my ($x, $y, $𝕩, $𝕪) = @_; # Coordinates of equiangles
34 my ($𝘅, $𝘆) = (0, $r); # Coordinates of apex
35 my ($nx, $ny, $nr) = ninePointCircle {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Coordinates of centre and radius of nine point circle
36 my ($cx, $cy) = centroid {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Coordinates of centroid
37 my ($ox, $oy) = orthoCentre {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Coordinates of orthocentre
38 ok near(100, $y); # Circumcentre to base of triangle
39 ok near(200, $cy); # Circumcentre to lower circumference of nine point circle
40 ok near(300, $y+$nr); # Circumcentre to centre of nine point circle
41 ok near(400, $𝘆); # Circumcentre to apex of isosceles triangle
42 ok near(500, $y+2*$nr); # Circumcentre to upper circumference of nine point circle
43 ok near(600, $oy); # Circumcentre to orthocentre
44 } 0, 0, $r, 0, $r/4, 1, $r/4; # Chord at 1/4 radius
45 }
46  
47 # A line segment across a circle is never longer than the diameter
48  
49 if (1) # Random circle and random line
50 {my ($x, $y, $r, $𝘅, $𝘆, $𝕩, $𝕪) = map {rand()} 1..7;
51 intersectionCircleLine # Find intersection of a circle and a line
52 {return ok 1 unless @_ == 4; # Ignore line unless it crosses circle
53 ok &vectorLength(@_) <= 2*$r; # Length if line segment is less than or equal to that of a diameter
54 } $x, $y, $r, $𝘅, $𝘆, $𝕩, $𝕪; # Circle and line to be intersected
55 }
56  
57 # The length of a side of a hexagon is the radius of a circle inscribed through
58 # its vertices
59  
60 if (1)
61 {my ($x, $y, $r) = map {rand()} 1..3; # Random circle
62 my @p = intersectionCircles {@_} $x, $y, $r, $x+$r, $y, $r; # First step of one radius
63 my @𝗽 = intersectionCircles {@_} $x, $y, $r, $p[0], $p[1], $r; # Second step of one radius
64 my @q = !&near($x+$r, $y, @𝗽[0,1]) ? @𝗽[0,1] : @𝗽[2,3]; # Away from start point
65 my @𝗾 = intersectionCircles {@_} $x, $y, $r, $q[0], $q[1], $r; # Third step of one radius
66 ok &near2(@𝗾[0,1], $x-$r, $y) or # Brings us to a point
67 &near2(@𝗾[2,3], $x-$r, $y); # opposite to the start point
68 }
69  
70 # Circle through three points chosen at random has the same centre regardless of
71 # the pairing of the points
72  
73 sub circleThrough3
74 {my ($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Three points
75 &intersectionLines
76 (sub # Intersection of bisectors is the centre of the circle
77 {my @r =(&vectorLength(@_, $x, $y), # Radii from centre of circle to each point
78 &vectorLength(@_, $𝘅, $𝘆),
79 &vectorLength(@_, $𝕩, $𝕪));
80 ok &near(@r[0,1]); # Check radii are equal
81 ok &near(@r[1,2]);
82 @_ # Return centre
83 }, rotate90AroundMidPoint($x, $y, $𝘅, $𝘆), # Bisectors between pairs of points
84 rotate90AroundMidPoint($𝕩, $𝕪, $𝘅, $𝘆));
85 }
86  
87 if (1)
88 {my (@points) = map {rand()} 1..6; # Three points chosen at random
89 ok &near2(circleThrough3(@points), circleThrough3(@points[2..5, 0..1])); # Circle has same centre regardless
90 ok &near2(circleThrough3(@points), circleThrough3(@points[4..5, 0..3])); # of the pairing of the points
91 }
92  
93 =cut
94 package Math::Intersection::Circle::Line;
95 #-------------------------------------------------------------------------------
96 # Locate the points at which lines and circles cross in two dimensions
97 # Philip R Brenan at gmail dot com, Appa Apps Ltd, 2016, http://www.appaapps.com
98 #-------------------------------------------------------------------------------
99  
100 1 ▶use v5.18;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 ▶use warnings FATAL => qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
105  
106 #-------------------------------------------------------------------------------
107 # Our definition of nearness
108 #-------------------------------------------------------------------------------
109  
110 1 our $near = 1e-6; # Define nearness
111  
112 14059 ▶sub near($;$) {return abs(($_[1]//0) - $_[0]) < $near} # Values this close are considered identical
Subroutine near: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[1] // 0
l!l
13395664
MC/DC100%1/1
$_[1] // 0
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
113  
114 sub near2($$;$$) # Check that we are near enough
115 172 ▶ {my ($a, $b, $A, $B) = @_;
Subroutine near2: called CC=4 SCAR=13.9
Pod documented
116 172 ▶ near($A//0, $a) &&
Branch: 1 branch
BranchTrueFalseTotal
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b) 63 109 172
Condition100%4/4
$A // 0
l!l
1702
$B // 0
l!l
612
MC/DC100%1/1
$A // 0
$A
MC/DC100%1/1
$B // 0
$B
Truth table100%2/2
A
A= $A
Aresult
11
00
Truth table100%2/2
A
A= $B
Aresult
11
00
117 near($B//0, $b)
118 }
119  
120 sub near3($$$;$$$) # Check that we are near enough
121 6 ▶ {my ($a, $b, $c, $A, $B, $C) = @_;
Subroutine near3: called CC=6 SCAR=18.6
Pod documented
122 6 ▶ near($A//0, $a) &&
Branch: 1 branch
BranchTrueFalseTotal
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b) and &near(scalar($C // 0), $c) 6 0 6
Condition77%7/9
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b)
!ll&&!rl&&r
006
$A // 0
l!l
51
$B // 0
l!l
51
$C // 0
l!l
51
MC/DC0%0/2
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b)
&near(scalar($A // 0), $a) &near(scalar($B // 0), $b)
MC/DC100%1/1
$A // 0
$A
MC/DC100%1/1
$B // 0
$B
MC/DC100%1/1
$C // 0
$C
Truth table33%1/3
A and B
A= &near(scalar($A // 0), $a)B= &near(scalar($B // 0), $b)
ABresult
0X0
100
111
Truth table100%2/2
A
A= $A
Aresult
11
00
Truth table100%2/2
A
A= $B
Aresult
11
00
Truth table100%2/2
A
A= $C
Aresult
11
00
123 near($B//0, $b) &&
124 near($C//0, $c)
125 }
126  
127 sub near4($$$$;$$$$) # Check that we are near enough
128 21 ▶ {my ($a, $b, $c, $d, $A, $B, $C, $D) = @_;
Subroutine near4: called CC=8 SCAR=22.4
Pod documented
129 21 ▶ near($A//0, $a) &&
Branch: 1 branch
BranchTrueFalseTotal
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b) and &near(scalar($C // 0), $c) and &near(scalar($D // 0), $d) 21 0 21
Condition71%10/14
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b) and &near(scalar($C // 0), $c)
!ll&&!rl&&r
0021
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b)
!ll&&!rl&&r
0021
$A // 0
l!l
201
$B // 0
l!l
201
$C // 0
l!l
201
$D // 0
l!l
201
MC/DC0%0/3
&near(scalar($A // 0), $a) and &near(scalar($B // 0), $b) and &near(scalar($C // 0), $c)
&near(scalar($A // 0), $a) &near(scalar($B // 0), $b) &near(scalar($C // 0), $c)
MC/DC100%1/1
$A // 0
$A
MC/DC100%1/1
$B // 0
$B
MC/DC100%1/1
$C // 0
$C
MC/DC100%1/1
$D // 0
$D
Truth table25%1/4
A and B and C
A= &near(scalar($A // 0), $a)B= &near(scalar($B // 0), $b)C= &near(scalar($C // 0), $c)
ABCresult
0XX0
10X0
1100
1111
Truth table100%2/2
A
A= $A
Aresult
11
00
Truth table100%2/2
A
A= $B
Aresult
11
00
Truth table100%2/2
A
A= $C
Aresult
11
00
Truth table100%2/2
A
A= $D
Aresult
11
00
130 near($B//0, $b) &&
131 near($C//0, $c) &&
132 near($D//0, $d)
133 }
134  
135 #-------------------------------------------------------------------------------
136 # Trigonometric functions
137 #-------------------------------------------------------------------------------
138  
139 134 ▶sub 𝝿 {4*atan2(1,1)} # Pi
Subroutine 𝝿: called CC=1 SCAR=0.0
Pod undocumented
140 6 ▶sub acos($) {my ($a) = @_; atan2(sqrt(1 - $a**2), $a)} # acos
Subroutine acos: called CC=1 SCAR=0.0
Pod documented
141  
142 #-------------------------------------------------------------------------------
143 # Length of a vector
144 #-------------------------------------------------------------------------------
145  
146 sub vectorSquaredLength($$;$$) # Length of a vector or distance between two vectors squared - useful for finding out which is longest without having to take a square root
147 5715 ▶ {my ($x, $y, $𝘅, $𝘆) = @_;
Subroutine vectorSquaredLength: called CC=3 SCAR=11.0
Pod undocumented
148 5715 ▶ my $r = ($x-($𝘅//0))**2+($y-($𝘆//0))**2;
Condition100%4/4
$𝘅 // 0
l!l
31722543
$𝘆 // 0
l!l
31722543
MC/DC100%1/1
$𝘅 // 0
$𝘅
MC/DC100%1/1
$𝘆 // 0
$𝘆
Truth table100%2/2
A
A= $𝘅
Aresult
11
00
Truth table100%2/2
A
A= $𝘆
Aresult
11
00
149 5715 $r
150 }
151  
152 5330 ▶sub vectorLength($$;$$) {sqrt(&vectorSquaredLength(@_))} # Length of a vector or distance between two vectors
Subroutine vectorLength: called CC=1 SCAR=0.0
Pod documented
153  
154 #-------------------------------------------------------------------------------
155 # Lengths of the sides of a polygon
156 #-------------------------------------------------------------------------------
157  
158 sub lengthsOfTheSidesOfAPolygon($$@)
159 5 ▶ {my ($x, $y, @vertices) = @_;
Subroutine lengthsOfTheSidesOfAPolygon: called CC=4 SCAR=13.9
Pod documented
160 5 ▶ @_% 2 == 0 or confess "Odd number of coordinates!";
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 or confess("Odd number of coordinates!") 5 0 5
161 5 ▶ @_> 4 or confess "Must have at least two vertices!";
Branch: 1 branch
BranchTrueFalseTotal
@_ > 4 or confess("Must have at least two vertices!") 5 0 5
162 5 my @l;
163 5 my ($𝘅, $𝘆);
164 5 ▶ for(;scalar(@vertices);)
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @vertices) 11 5 16
165 11 {($𝘅, $𝘆, @vertices) = @vertices;
166 11 push @l, vectorLength($x, $y, $𝘅, $𝘆);
167 11 ($x, $y) = ($𝘅, $𝘆)
168 }
169 5 push @l, vectorLength($_[-2]-$_[0], $_[-1]-$_[1]);
170 @l
171 5 }
172  
173 #-------------------------------------------------------------------------------
174 # Check whether three points are close to collinear by the Schwartz inequality
175 #-------------------------------------------------------------------------------
176  
177 sub threeCollinearPoints($$$$$$) # Three points to be tested
178 794 ▶ {my ($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_;
Subroutine threeCollinearPoints: called CC=14 SCAR=27.0
Pod documented
179 794 ▶ @_ == 6 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 6 or confess("Wrong number of parameters") 794 0 794
180 794 ▶ return 1 if near($x, $𝘅) && near($y, $𝘆) or near($x, $𝕩) && near($y, $𝕪); # When two points are close the points are effectively collinear - although we should really check that all three points are not close sa this would identify either a number representation problem or a bad definition of nearness for this application
Branch: 1 branch
BranchTrueFalseTotal
if &near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪) 1 793 794
Condition77%7/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪)
l!l&&r!l&&!r
01793
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
710840
&near($x, $𝕩) and &near($y, $𝕪)
!ll&&!rl&&r
714791
MC/DC50%2/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($x, $𝕩) &near($y, $𝕪)
Truth table71%5/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($x, $𝕩)D= &near($y, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
181 793 my $d = vectorLength($𝘅, $𝘆, $𝕩, $𝕪);
182 793 my $𝗱 = vectorLength($x, $y, $𝕩, $𝕪); # Lengths of sides opposite corners
183 793 my $𝕕 = vectorLength($x, $y, $𝘅, $𝘆);
184 793 ▶ return 1 if near($d, $𝗱) && near($𝕕); # Two sides equal and the other small makes the lines effectively collinear
Branch: 1 branch
BranchTrueFalseTotal
if &near($d, $𝗱) and &near($𝕕) 0 793 793
Condition66%2/3
&near($d, $𝗱) and &near($𝕕)
!ll&&!rl&&r
757360
MC/DC0%0/2
&near($d, $𝗱) and &near($𝕕)
&near($d, $𝗱) &near($𝕕)
Truth table66%2/3
A and B
A= &near($d, $𝗱)B= &near($𝕕)
ABresult
0X0
100
111
185 793 ▶ return 1 if near($d, $𝕕) && near($𝗱);
Branch: 1 branch
BranchTrueFalseTotal
if &near($d, $𝕕) and &near($𝗱) 0 793 793
Condition66%2/3
&near($d, $𝕕) and &near($𝗱)
!ll&&!rl&&r
779140
MC/DC0%0/2
&near($d, $𝕕) and &near($𝗱)
&near($d, $𝕕) &near($𝗱)
Truth table66%2/3
A and B
A= &near($d, $𝕕)B= &near($𝗱)
ABresult
0X0
100
111
186 793 ▶ return 1 if near($𝗱, $𝕕) && near($d);
Branch: 1 branch
BranchTrueFalseTotal
if &near($𝗱, $𝕕) and &near($d) 1 792 793
Condition100%3/3
&near($𝗱, $𝕕) and &near($d)
!ll&&!rl&&r
763291
MC/DC100%2/2
&near($𝗱, $𝕕) and &near($d)
&near($𝗱, $𝕕) &near($d)
Truth table100%3/3
A and B
A= &near($𝗱, $𝕕)B= &near($d)
ABresult
0X0
100
111
187 792 ▶ near($d, $𝗱+$𝕕) or near($𝗱, $𝕕+$d) or near($𝕕, $d+$𝗱) # One side is almost as long as the other two combined
Branch: 1 branch
BranchTrueFalseTotal
&near($d, $𝗱 + $𝕕) or &near($𝗱, $𝕕 + $d) or &near($𝕕, $d + $𝗱) 90 702 792
Condition100%3/3
&near($d, $𝗱 + $𝕕) or &near($𝗱, $𝕕 + $d)
l!l&&r!l&&!r
4446702
MC/DC100%2/2
&near($d, $𝗱 + $𝕕) or &near($𝗱, $𝕕 + $d)
&near($d, $𝗱 + $𝕕) &near($𝗱, $𝕕 + $d)
Truth table100%3/3
A or B
A= &near($d, $𝗱 + $𝕕)B= &near($𝗱, $𝕕 + $d)
ABresult
1X1
011
000
188 }
189  
190 #-------------------------------------------------------------------------------
191 # Average of two vectors = coordinates of the mid point on the line between them
192 #-------------------------------------------------------------------------------
193  
194 sub midPoint($$$$)
195 219 ▶ {my ($x, $y, $𝘅, $𝘆) = @_;
Subroutine midPoint: called CC=2 SCAR=7.1
Pod documented
196 219 ▶ @_ == 4 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Wrong number of parameters") 219 0 219
197 219 (($x+$𝘅) / 2, ($y+$𝘆) / 2)
198 }
199  
200 #-------------------------------------------------------------------------------
201 # Rotations
202 #-------------------------------------------------------------------------------
203  
204 104 ▶sub rotate90CW ($$) {my ($x, $y) = @_; (+$y, -$x)} # Clockwise
Subroutine rotate90CW: called CC=1 SCAR=0.0
Pod documented
205 2 ▶sub rotate90CCW($$) {my ($x, $y) = @_; (-$y, +$x)} # Counter clockwise
Subroutine rotate90CCW: called CC=1 SCAR=0.0
Pod documented
206  
207 sub rotate90AroundMidPoint($$$$)
208 102 ▶ {my ($x, $y, $𝘅, $𝘆) = @_;
Subroutine rotate90AroundMidPoint: called CC=2 SCAR=7.0
Pod documented
209 102 ▶ @_ == 4 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or confess("Wrong number of parameters") 102 0 102
210 102 my ($𝕩, $𝕪) = map {$_/2} rotate90CW($𝘅 - $x, $𝘆 - $y);
211 102 my ($X, $Y) = &midPoint(@_);
212 102 ($X - $𝕩, $Y - $𝕪, $X + $𝕩, $Y + $𝕪)
213 }
214  
215 #-------------------------------------------------------------------------------
216 # 𝗜ntersection of a circle A, with a circle B.
217 #
218 # 𝗞nown: coordinates of the centre and radius of each circle x, y, r, 𝘅, 𝘆, 𝗿
219 #
220 # 𝗙ind: the coordinates of the points at which the circles intersect.
221 #
222 # 𝗠ethod: Two different circles either do not intersect, or if they do, they
223 # intersect at one or two points. If they intersect at two points, the
224 # intersections are mirror images of each other in the line that connects the
225 # centres of the two circles.
226 #
227 # Let 𝗟 be the line joining the two centres with length 𝗹 = a + 𝗮 where a is the
228 # distance from (x, y) along 𝗟 to the point closest to the intersections. Then:
229 #
230 # r*r-a*a == 𝗿*𝗿-𝗮*𝗮
231 # r*r-𝗿*𝗿 == a*a-𝗮*𝗮
232 # == a*a-𝗮*𝗮 = (a+𝗮)(a-𝗮) == 𝗹*(a-𝗮) == 𝗹*(a - (𝗹 - a)) = 2*a*𝗹 - 𝗹*𝗹
233 #
234 # a == (r*r-𝗿*𝗿 + 𝗹*𝗹)/ (2*𝗹)
235 #
236 # The distance 𝗮 at right angles to 𝗟 to an intersection is sqrt(r*r-a*a)
237 #
238 # The unit vector 𝕕 == (𝕩, 𝕪) along line 𝗟 from (x,y) to (𝘅, 𝘆) is the unit in
239 # direction: (𝘅-x, 𝘆-y)
240 #
241 # The unit vectors d, 𝗱 at right angles to 𝗟 are (-𝕪, 𝕩) and (𝕪, -𝕩)
242 #-------------------------------------------------------------------------------
243  
244 sub intersectionCircles(&$$$$$$)
245 695 ▶ {my ($sub, # Sub routine to process intersection
Subroutine intersectionCircles: called CC=9 SCAR=22.0
Pod documented
246 $x, $y, $r, # First circle centre, radius
247 $𝘅, $𝘆, $𝗿) = @_; # Second circle centre, radius
248 695 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 695 0 695
249 695 ▶ return &$sub("Duplicate circles!") if # Complain if the two circles are in fact the same circle within the definition of nearness
Branch: 1 branch
BranchTrueFalseTotal
if &near($x, $𝘅) and &near($y, $𝘆) and &near($r, $𝗿) 1 694 695
Condition100%6/6
&near($x, $𝘅) and &near($y, $𝘆) and &near($r, $𝗿)
!ll&&!rl&&r
69221
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
612803
MC/DC100%3/3
&near($x, $𝘅) and &near($y, $𝘆) and &near($r, $𝗿)
&near($x, $𝘅) &near($y, $𝘆) &near($r, $𝗿)
Truth table100%4/4
A and B and C
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($r, $𝗿)
ABCresult
0XX0
10X0
1100
1111
250 near($x, $𝘅) and near($y, $𝘆) and near($r, $𝗿);
251  
252 694 my ($𝕏, $𝕐) = ($𝘅 - $x, $𝘆 - $y); # Vector between centres
253 694 my $𝗹 = vectorLength($𝕏, $𝕐); # Distance between centres
254 694 ▶ return &$sub("No intersection!") if $𝗹 > $r + $𝗿 or $𝗹 < abs($r - $𝗿); # The circles are too far apart or too close to intersect
Branch: 1 branch
BranchTrueFalseTotal
if $𝗹 > $r + $𝗿 or $𝗹 < abs $r - $𝗿 3 691 694
Condition100%3/3
$𝗹 > $r + $𝗿 or $𝗹 < abs $r - $𝗿
l!l&&r!l&&!r
12691
MC/DC100%2/2
$𝗹 > $r + $𝗿 or $𝗹 < abs $r - $𝗿
$𝗹 > $r + $𝗿 $𝗹 < abs $r - $𝗿
Truth table100%3/3
A or B
A= $𝗹 > $r + $𝗿B= $𝗹 < abs $r - $𝗿
ABresult
1X1
011
000
255  
256 691 my ($𝕩, $𝕪) = ($𝕏 / $𝗹, $𝕐 / $𝗹); # Unit vector between centres
257 691 my $a = ($r*$r - $𝗿*$𝗿 + $𝗹*$𝗹)/ (2*$𝗹); # Length of the common side
258  
259 691 ▶ return &$sub($x+$𝕩*$a, $y+$𝕪*$a) if near($𝗹, $r + $𝗿) or # The circles touch at one point if within the definition of nearness
Branch: 1 branch
BranchTrueFalseTotal
if &near($𝗹, $r + $𝗿) or &near($𝗹, abs $r - $𝗿) 6 685 691
Condition100%3/3
&near($𝗹, $r + $𝗿) or &near($𝗹, abs $r - $𝗿)
l!l&&r!l&&!r
24685
MC/DC100%2/2
&near($𝗹, $r + $𝗿) or &near($𝗹, abs $r - $𝗿)
&near($𝗹, $r + $𝗿) &near($𝗹, abs $r - $𝗿)
Truth table100%3/3
A or B
A= &near($𝗹, $r + $𝗿)B= &near($𝗹, abs $r - $𝗿)
ABresult
1X1
011
000
260 near($𝗹, abs($r - $𝗿));
261  
262 685 my $𝗮 = sqrt($r*$r-$a*$a);
263 685 &$sub($x+$𝕩*$a-$𝕪*$𝗮, $y+$𝕪*$a+$𝕩*$𝗮, # The circles touch at two points
264 $x+$𝕩*$a+$𝕪*$𝗮, $y+$𝕪*$a-$𝕩*$𝗮);
265 }
266  
267 #-------------------------------------------------------------------------------
268 # 𝗔rea of intersection of two circles.
269 #
270 # 𝗞nown: two circles specified by ($x, $y, $r) and ($𝘅, $𝘆, $𝗿)
271 #
272 # 𝗙ind: the area of intersection expressed as a fraction of the area
273 # of the smaller circle
274 #
275 # 𝗠ethod: the area of a triangle is (base * height) / 2, the area of a slice is
276 # 𝝰𝗿𝗿/2 where 𝝰 is the angle of a slice.
277 #-------------------------------------------------------------------------------
278  
279 sub intersectionCirclesArea(&$$$$$$)
280 10 ▶ {my ($sub, # Sub routine to process area
Subroutine intersectionCirclesArea: called CC=7 SCAR=19.6
Pod documented
281 $x, $y, $r, # First circle centre, radius
282 $𝘅, $𝘆, $𝗿) = @_; # Second circle centre, radius
283 10 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 10 0 10
284 10 ▶ near($r) and confess "Radius of first circle is too small!";
Branch: 1 branch
BranchTrueFalseTotal
&near($r) and confess("Radius of first circle is too small!") 0 10 10
285 10 ▶ near($𝗿) and confess "Radius of second circle is too small!";
Branch: 1 branch
BranchTrueFalseTotal
&near($𝗿) and confess("Radius of second circle is too small!") 0 10 10
286 10 my $l = vectorLength($𝘅 - $x, $𝘆 - $y); # Distance between centres
287 10 ▶ return &$sub(0) if $l >= $r + $𝗿; # The circles are too far apart to overlap
Branch: 1 branch
BranchTrueFalseTotal
if $l >= $r + $𝗿 1 9 10
288 9 ▶ my $𝕣 = $r < $𝗿 ? $r : $𝗿; # Radius of smaller circle
Branch: 1 branch
BranchTrueFalseTotal
$r < $𝗿 ? : 5 4 9
289 9 ▶ return &$sub(1) if $l <= abs($r - $𝗿); # The larger circle overlaps the smaller circle completely
Branch: 1 branch
BranchTrueFalseTotal
if $l <= abs $r - $𝗿 3 6 9
290  
291 intersectionCircles
292 6 ▶ {my ($X, $Y, $𝗫, $𝗬) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
293 6 my $h = vectorLength($X - $𝗫, $Y - $𝗬) / 2; # Height of triangles
294 6 my $R = sqrt($r**2 - $h**2); # Base of triangle in first circle
295 6 my $𝗥 = sqrt($𝗿**2 - $h**2); # Base of triangle in second circle
296 6 &$sub(($r**2*atan2($h, $R) + $𝗿**2*atan2($h, $𝗥) - $h*($R+$𝗥))/(𝝿()*$𝕣**2)) # Fraction of smaller circle overlapped
297 6 } $x, $y, $r, $𝘅, $𝘆, $𝗿;
298 }
299  
300 #-------------------------------------------------------------------------------
301 # 𝗣osition on a line closest to a specified point
302 #
303 # 𝗞nown: two points on the line 𝗟 such that: 𝗹 = (𝘅, 𝘆), 𝕝 = (𝕩, 𝕪) and the
304 # specified point 𝗽 = (x, y).
305 #
306 # 𝗙ind 𝗰 the point on 𝗟 closest to 𝗽.
307 #
308 # 𝗠ethod: a circle with centre 𝗹 through 𝗽 will intersect a circle with centre 𝕝
309 # through 𝗽 at 𝗾. 𝗰 is then the average of 𝗽 and 𝗾.
310 #-------------------------------------------------------------------------------
311  
312 sub intersectionLinePoint(&$$$$$$)
313 796 ▶ {my ($sub, # Sub routine to process intersection
Subroutine intersectionLinePoint: called CC=9 SCAR=22.1
Pod documented
314 $𝘅, $𝘆, $𝕩, $𝕪, # Two points on line 𝗹
315 $x, $y) = @_; # The point 𝗽
316 796 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 796 0 796
317 796 ▶ near($𝘅, $𝕩) and near($𝘆, $𝕪) and confess "Points on line are too close!"; # Line not well defined
Branch: 1 branch
BranchTrueFalseTotal
&near($𝘅, $𝕩) and &near($𝘆, $𝕪) and confess("Points on line are too close!") 0 796 796
Condition66%2/3
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
713830
MC/DC0%0/2
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table66%2/3
A and B
A= &near($𝘅, $𝕩)B= &near($𝘆, $𝕪)
ABresult
0X0
100
111
318  
319 796 ▶ return &$sub($x, $y) if near($x, $𝘅) && near($y, $𝘆) or # Point in question is near an end of the line segment
Branch: 1 branch
BranchTrueFalseTotal
if &near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪) 11 785 796
Condition100%9/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪)
l!l&&r!l&&!r
65785
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
711796
&near($x, $𝕩) and &near($y, $𝕪)
!ll&&!rl&&r
772135
MC/DC100%4/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($x, $𝕩) and &near($y, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($x, $𝕩) &near($y, $𝕪)
Truth table100%7/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($x, $𝕩)D= &near($y, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
320 near($x, $𝕩) && near($y, $𝕪);
321  
322 785 ▶ return &$sub($x, $y) if threeCollinearPoints($𝘅, $𝘆, $𝕩, $𝕪, $x, $y); # Collinear
Branch: 1 branch
BranchTrueFalseTotal
if &threeCollinearPoints($𝘅, $𝘆, $𝕩, $𝕪, $x, $y) 119 666 785
323 # Points known not to be collinear
324 666 my $𝗿 = vectorLength($𝘅 - $x, $𝘆 - $y); # Radius of first circle
325 666 my $𝕣 = vectorLength($𝕩 - $x, $𝕪 - $y); # Radius of second circle
326 intersectionCircles
327 666 ▶ {return &$sub(@_) if @_ == 2; # Point is on line
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 0 666 666
328 666 my ($x, $y, $𝘅, $𝘆) = @_;
329 666 &$sub(($x+$𝘅) / 2, ($y+$𝘆) / 2) # Average intersection of intersection points
330 666 } $𝘅, $𝘆, $𝗿, $𝕩, $𝕪, $𝕣;
331 }
332  
333 sub unsignedDistanceFromLineToPoint(&$$$$$$) # Unsigned distance from point to line
334 287 ▶ {my ($sub, $𝘅, $𝘆, $𝕩, $𝕪, $x, $y) = @_; # Parameters are the same as for intersectionLinePoint()
Subroutine unsignedDistanceFromLineToPoint: called CC=2 SCAR=7.0
Pod undocumented
335 287 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 287 0 287
336 287 ▶ intersectionLinePoint {&$sub(&vectorLength($x, $y, @_))} $𝘅,$𝘆, $𝕩,$𝕪, $x,$y; # Distance from point to nearest point on line
Subroutine __ANON__: called CC=1 SCAR=0.0
337 }
338  
339 #-------------------------------------------------------------------------------
340 # 𝗜ntersection of two lines
341 #
342 # 𝗞nown: two lines l specified by two points 𝗹 = (𝘅, 𝘆), 𝕝 = (𝕩, 𝕪) and
343 # L specified by two points 𝗟 = (𝗫, 𝗬), 𝕃 = (𝕏, 𝕐)
344 # 𝗙ind 𝗰 the point where the two lines intersect else $sub is called empty
345 #
346 # 𝗠ethod: Let the closest point to point 𝗟 on line l be 𝗮 and the closest point
347 # to point 𝗮 on line L be 𝗯. L𝗮𝗯 is similar to L𝗮𝗰.
348 #-------------------------------------------------------------------------------
349  
350 sub intersectionLines(&$$$$$$$$)
351 196 ▶ {my ($sub, # Sub routine to process intersection
Subroutine intersectionLines: called CC=7 SCAR=19.9
Pod documented
352 $𝘅, $𝘆, $𝕩, $𝕪, # Two points on line l
353 $𝗫, $𝗬, $𝕏, $𝕐) = @_; # Two points on line L
354 196 ▶ @_ == 9 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 9 or confess("Wrong number of parameters") 196 0 196
355 196 ▶ near($𝘅, $𝕩) and near($𝘆, $𝕪) and confess "Points on first line are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($𝘅, $𝕩) and &near($𝘆, $𝕪) and confess("Points on first line are too close!") 0 196 196
Condition66%2/3
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
172240
MC/DC0%0/2
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table66%2/3
A and B
A= &near($𝘅, $𝕩)B= &near($𝘆, $𝕪)
ABresult
0X0
100
111
356 196 ▶ near($𝗫, $𝕏) and near($𝗬, $𝕐) and confess "Points on second line are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($𝗫, $𝕏) and &near($𝗬, $𝕐) and confess("Points on second line are too close!") 0 196 196
Condition66%2/3
&near($𝗫, $𝕏) and &near($𝗬, $𝕐)
!ll&&!rl&&r
153430
MC/DC0%0/2
&near($𝗫, $𝕏) and &near($𝗬, $𝕐)
&near($𝗫, $𝕏) &near($𝗬, $𝕐)
Truth table66%2/3
A and B
A= &near($𝗫, $𝕏)B= &near($𝗬, $𝕐)
ABresult
0X0
100
111
357 196 ▶ return &$sub("Parallel lines!") if # Lines are parallel if they have the same gradient
Branch: 1 branch
BranchTrueFalseTotal
if &near(atan2($𝘆 - $𝕪, $𝘅 - $𝕩), atan2($𝗬 - $𝕐, $𝗫 - $𝕏)) 3 193 196
358 near(atan2($𝘆-$𝕪, $𝘅-$𝕩), atan2($𝗬-$𝕐, $𝗫-$𝕏));
359  
360 intersectionLinePoint # Find 𝗮
361 193 ▶ {my ($𝗮x, $𝗮y) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
362  
363 intersectionLinePoint # Find 𝗯
364 193 ▶ {my ($𝗯x, $𝗯y) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
365 193 my $La = vectorSquaredLength($𝗫 - $𝗮x, $𝗬 - $𝗮y); # Squared distance from 𝗟 to 𝗮
366 193 ▶ return &$sub($𝗫, $𝗬) if near($La); # End point of second line is on first line but the lines are not parallel
Branch: 1 branch
BranchTrueFalseTotal
if &near($La) 1 192 193
367 192 my $Lb = vectorSquaredLength($𝗫 - $𝗯x, $𝗬 - $𝗯y); # Squared distance from 𝗟 to 𝗯
368 192 ▶ near($Lb) and confess "Parallel lines!"; # Although this should not happen as we have already checked that the lines are not parallel
Branch: 1 branch
BranchTrueFalseTotal
&near($Lb) and confess("Parallel lines!") 0 192 192
369 192 my $s = $La / $Lb; # Scale factor for 𝗟𝗯
370 192 &$sub($𝗫 + $s * ($𝗯x - $𝗫), $𝗬 + $s * ($𝗯y - $𝗬)) # Point of intersection
371 193 } $𝗫,$𝗬, $𝕏,$𝕐, $𝗮x,$𝗮y; # Find 𝗯 on second line
372 193 } $𝘅,$𝘆, $𝕩,$𝕪, $𝗫,$𝗬; # Find 𝗮 on first line
373 }
374  
375 #-------------------------------------------------------------------------------
376 # 𝗜ntersection of a circle with a line
377 #
378 # 𝗞nown: a circle specified by its centre (x, y), and radius (r)
379 # and a line that passes through points: ($𝘅, $𝘆) and ($𝕩, $𝕪).
380 #
381 # 𝗙ind: the two points at which the line crosses the circle or the single point
382 # at which the line touches the circle or report that there are no points in
383 # common.
384 #
385 # 𝗠ethod: If the line crosses the circle we can draw an isosceles triangle from
386 # the centre of the circle to the points of intersection, with the line forming
387 # the base of said triangle. The centre of the base is the closest point on the
388 # line to the centre of the circle. The line is at right angles to the line from
389 # the centre of the circle to the centre of the base.
390 #-------------------------------------------------------------------------------
391  
392 sub intersectionCircleLine(&$$$$$$$)
393 66 ▶ {my ($sub, # Sub routine to process intersection
Subroutine intersectionCircleLine: called CC=6 SCAR=17.9
Pod documented
394 $x, $y, $r, # Circle centre, radius
395 $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Line goes through these two points
396 66 ▶ @_ == 8 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 8 or confess("Wrong number of parameters") 66 0 66
397 66 ▶ near($𝘅, $𝕩) and near($𝘆, $𝕪) and confess "Points on line are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($𝘅, $𝕩) and &near($𝘆, $𝕪) and confess("Points on line are too close!") 1 65 66
Condition100%3/3
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
6051
MC/DC100%2/2
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table100%3/3
A and B
A= &near($𝘅, $𝕩)B= &near($𝘆, $𝕪)
ABresult
0X0
100
111
398 65 ▶ if (near($r)) # Zero radius circle
Branch: 1 branch
BranchTrueFalseTotal
if (&near($r)) 1 64 65
399 1 ▶ {return &$sub($x, $y) if threeCollinearPoints($x, $y, $𝘅, $𝘆, $𝕩, $𝕪); # Line passes through the centre of the circle
Branch: 1 branch
BranchTrueFalseTotal
if &threeCollinearPoints($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) 1 0 1
400 0 confess "Radius is too small!";
401 }
402  
403 intersectionLinePoint
404 64 ▶ {my ($X, $Y) = @_; # Midpoint on line
Subroutine __ANON__: called CC=5 SCAR=16.1
405 64 ▶ if (near($x, $X) and near($y, $Y)) # Line passes through centre of circle
Branch: 1 branch
BranchTrueFalseTotal
if (&near($x, $X) and &near($y, $Y)) 11 53 64
Condition100%3/3
&near($x, $X) and &near($y, $Y)
!ll&&!rl&&r
44911
MC/DC100%2/2
&near($x, $X) and &near($y, $Y)
&near($x, $X) &near($y, $Y)
Truth table100%3/3
A and B
A= &near($x, $X)B= &near($y, $Y)
ABresult
0X0
100
111
406 11 {my ($𝗫, $𝗬) = ($𝕩 - $𝘅, $𝕪 - $𝘆); # Vector along line
407 11 my $D = vectorLength($𝗫, $𝗬); # Length of vector along line
408 11 my $s = $r/$D; # Length from midpoint along line to circumference relative to length from centre to midpoint
409 11 return &$sub($x + $s * $𝗫, $y + $s * $𝗬, $x - $s * $𝗫, $y - $s * $𝗬); # Intersection points
410 }
411 53 my ($𝗫, $𝗬) = ($X - $x, $Y - $y); # Centre to midpoint
412 53 my $𝗗 = vectorLength($𝗫, $𝗬); # Distance to midpoint
413 53 ▶ return &$sub("No intersection!") if $𝗗 > $r; # Midpoint outside circle
Branch: 1 branch
BranchTrueFalseTotal
if $𝗗 > $r 2 51 53
414 51 ▶ return &$sub($X, $Y) if near($𝗗, $r); # Tangent
Branch: 1 branch
BranchTrueFalseTotal
if &near($𝗗, $r) 3 48 51
415 48 my $𝔻 = sqrt($r*$r - $𝗗*$𝗗); # Length from midpoint along line to circumference
416 48 my $s = $𝔻/$𝗗; # Length from midpoint along line to circumference relative to length from centre to midpoint
417 48 &$sub($X - $s * $𝗬, $Y + $s * $𝗫, $X + $s * $𝗬, $Y - $s * $𝗫) # Intersection points
418 64 } $𝘅, $𝘆, $𝕩, $𝕪, $x, $y; # Find point on line closest to centre of circle
419 }
420  
421 #-------------------------------------------------------------------------------
422 # 𝗔rea of intersection of a circle with a line
423 #
424 # 𝗞nown: a circle specified by its centre (x, y), and radius (r)
425 # and a line that passes through points: ($𝘅, $𝘆) and ($𝕩, $𝕪).
426 # 𝗙ind: the area of the smallest lune as a fraction of the area of the circle
427 # 𝗠ethod:
428 #-------------------------------------------------------------------------------
429  
430 sub intersectionCircleLineArea(&$$$$$$$)
431 49 ▶ {my ($sub, # Sub routine to process area
Subroutine intersectionCircleLineArea: called CC=5 SCAR=16.7
Pod documented
432 $x, $y, $r, # Circle centre, radius
433 $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Line goes through these two points
434 49 ▶ @_ == 8 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 8 or confess("Wrong number of parameters") 49 0 49
435 49 ▶ near($𝘅, $𝕩) and near($𝘆, $𝕪) and confess "Points on line are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($𝘅, $𝕩) and &near($𝘆, $𝕪) and confess("Points on line are too close!") 0 49 49
Condition33%1/3
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
4900
MC/DC0%0/2
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table33%1/3
A and B
A= &near($𝘅, $𝕩)B= &near($𝘆, $𝕪)
ABresult
0X0
100
111
436 49 ▶ near($r) and confess "Radius is too small!";
Branch: 1 branch
BranchTrueFalseTotal
&near($r) and confess("Radius is too small!") 0 49 49
437  
438 intersectionCircleLine
439 49 ▶ {return &$sub(0) if @_ < 4;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 4 3 46 49
440 46 my ($X, $Y, $𝗫, $𝗬) = @_; # Intersection points
441 46 my $h = vectorLength($X - $𝗫, $Y - $𝗬) / 2; # Height of triangle
442 46 my $w = sqrt($r**2 - $h**2); # Base of triangle
443 46 &$sub(($r**2*atan2($h, $w) - $h*$w)/(𝝿()*$r**2)) # Area of smallest lune as a fraction of circle
444 49 } $x, $y, $r, $𝘅, $𝘆, $𝕩, $𝕪;
445 }
446  
447 #-------------------------------------------------------------------------------
448 # 𝗖ircumCentre: intersection of the sides of a triangle when rotated 𝝿/2 at
449 # their mid points - centre of the circumCircle
450 # 𝗞nown: coordinates of each corner of the triangle
451 #-------------------------------------------------------------------------------
452  
453 sub circumCentre(&$$$$$$)
454 46 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine circumCentre: called CC=6 SCAR=19.9
Pod documented
455 46 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 46 0 46
456 46 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 46 46
Condition55%5/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0046
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
4510
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
4510
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table42%3/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
457  
458 46 ▶ &intersectionLines(sub{&$sub(@_)},
Subroutine __ANON__: called CC=1 SCAR=0.0
459 46 rotate90AroundMidPoint($x, $y, $𝘅, $𝘆),
460 rotate90AroundMidPoint($𝘅, $𝘆, $𝕩, $𝕪));
461 }
462  
463 #-------------------------------------------------------------------------------
464 # 𝗖ircle through three points: https://en.wikipedia.org/wiki/Circumscribed_circle
465 # 𝗞nown: coordinates of each point
466 # 𝗙ind: coordinates of the centre and radius of the circle through these three
467 # points
468 #-------------------------------------------------------------------------------
469  
470 sub circumCircle(&$$$$$$)
471 46 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine circumCircle: called CC=6 SCAR=20.1
Pod documented
472 46 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 46 0 46
473 46 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Points are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Points are too close!") 0 46 46
Condition55%5/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0046
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
4510
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
4510
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table42%3/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
474  
475 circumCentre
476 46 ▶ {my ($X, $Y) = @_; # Centre
Subroutine __ANON__: called CC=3 SCAR=12.0
477 46 my @r = (vectorLength($x, $y, $X, $Y), # Radii
478 vectorLength($𝘅, $𝘆, $X, $Y),
479 vectorLength($𝕩, $𝕪, $X, $Y));
480 46 ▶ &near(@r[0,1]) && &near(@r[1,2]) or confess "Bad radius computed!";
Branch: 1 branch
BranchTrueFalseTotal
&near(@r[0, 1]) and &near(@r[1, 2]) or confess("Bad radius computed!") 46 0 46
Condition33%1/3
&near(@r[0, 1]) and &near(@r[1, 2])
!ll&&!rl&&r
0046
MC/DC0%0/2
&near(@r[0, 1]) and &near(@r[1, 2])
&near(@r[0, 1]) &near(@r[1, 2])
Truth table33%1/3
A and B
A= &near(@r[0, 1])B= &near(@r[1, 2])
ABresult
0X0
100
111
481 46 &$sub($X, $Y, $r[0]) # Result
482 46 } $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Centre lies at the intersection of
483 }
484  
485 #-------------------------------------------------------------------------------
486 # 𝗖entre of a circle inscribed inside a triangle so that the inscribed circle
487 # touches each side just once.
488 #
489 # 𝗞nown: coordinates of each corner of the triangle
490 # 𝗙ind: centre coordinates and radius of inscribed circle
491 # 𝗠ethod: find the intersection of the lines bisecting two angles
492 #-------------------------------------------------------------------------------
493  
494 sub circleInscribedInTriangle(&$$$$$$)
495 1 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine circleInscribedInTriangle: called CC=6 SCAR=20.1
Pod documented
496 1 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 1 0 1
497 1 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 1 1
Condition33%3/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
001
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
100
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
010
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table14%1/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
498 1 my $𝗱 = vectorLength($x, $y, $𝕩, $𝕪); # Lengths of sides opposite corners
499 1 my $𝕕 = vectorLength($x, $y, $𝘅, $𝘆);
500 1 my $d = vectorLength($𝘅, $𝘆, $𝕩, $𝕪);
501  
502 intersectionLines
503 1 ▶ {my ($X, $Y) = @_; # Intersection point
Subroutine __ANON__: called CC=3 SCAR=11.4
504 1 ▶ my @r = ((unsignedDistanceFromLineToPoint {@_} $x, $y, $𝘅, $𝘆, $X, $Y),
Subroutine __ANON__: called CC=1 SCAR=0.0
505 1 ▶ (unsignedDistanceFromLineToPoint {@_} $𝘅, $𝘆, $𝕩, $𝕪, $X, $Y),
Subroutine __ANON__: called CC=1 SCAR=0.0
506 1 ▶ (unsignedDistanceFromLineToPoint {@_} $𝕩, $𝕪, $x, $y, $X, $Y));
Subroutine __ANON__: called CC=1 SCAR=0.0
507 1 ▶ &near(@r[0,1]) && &near(@r[1,2]) or confess "Bad radius computed!";
Branch: 1 branch
BranchTrueFalseTotal
&near(@r[0, 1]) and &near(@r[1, 2]) or confess("Bad radius computed!") 1 0 1
Condition33%1/3
&near(@r[0, 1]) and &near(@r[1, 2])
!ll&&!rl&&r
001
MC/DC0%0/2
&near(@r[0, 1]) and &near(@r[1, 2])
&near(@r[0, 1]) &near(@r[1, 2])
Truth table33%1/3
A and B
A= &near(@r[0, 1])B= &near(@r[1, 2])
ABresult
0X0
100
111
508 1 return &$sub($X, $Y, $r[0]); # Coordinates of the centre of the inscribed circle, plus three estimates of its radius
509 }
510 1 $x, $y, $x + ($𝘅-$x)/$𝕕 + ($𝕩-$x)/$𝗱, $y + ($𝘆-$y)/$𝕕 + ($𝕪-$y)/$𝗱, # Intersection of an angle bisector
511 $𝘅, $𝘆, $𝘅 + ($𝕩-$𝘅)/$d + ($x-$𝘅)/$𝕕, $𝘆 + ($𝕪-$𝘆)/$d + ($y-$𝘆)/$𝕕; # Intersection of an angle bisector
512 }
513  
514 #-------------------------------------------------------------------------------
515 # 𝗖entre of a circle inscribed through the midpoints of each side of a triangle
516 # == Nine point circle: https://en.wikipedia.org/wiki/Nine-point_circle
517 # 𝗞nown: coordinates of each corner of the triangle
518 # 𝗙ind: centre coordinates and radius of circle through midpoints
519 # 𝗠ethod: use circumCircle on the midpoints
520 #-------------------------------------------------------------------------------
521  
522 sub ninePointCircle(&$$$$$$)
523 24 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine ninePointCircle: called CC=6 SCAR=20.9
Pod documented
524 24 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 24 0 24
525 24 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 24 24
Condition44%4/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0024
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
2400
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
2220
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table28%2/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
526  
527 24 ▶ &circumCircle(sub{&$sub(@_)}, # Circle through mid points
Subroutine __ANON__: called CC=1 SCAR=0.0
528 24 midPoint($x, $y, $𝘅, $𝘆),
529 midPoint($𝘅, $𝘆, $𝕩, $𝕪),
530 midPoint($𝕩, $𝕪, $x, $y));
531 }
532  
533 #-------------------------------------------------------------------------------
534 # Bisect the first angle of a triangle
535 #-------------------------------------------------------------------------------
536  
537 sub bisectAnAngle(&$$$$$$)
538 114 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine bisectAnAngle: called CC=6 SCAR=20.5
Pod undocumented
539 114 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 114 0 114
540 114 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 114 114
Condition44%4/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
00114
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
11400
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
11310
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table28%2/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
541 114 my $𝕕 = vectorLength($x, $y, $𝕩, $𝕪); # Lengths to opposite corners
542 114 my $𝗱 = vectorLength($x, $y, $𝘅, $𝘆);
543 114 &$sub($x, $y, $x + ($𝘅-$x)/$𝕕 + ($𝕩-$x)/$𝗱, $y + ($𝘆-$y)/$𝕕 + ($𝕪-$y)/$𝗱) # Vector from vertex pointing along bisector
544 }
545  
546 #-------------------------------------------------------------------------------
547 # 𝗙ind the centres and radii of the excircles of a triangle
548 # https://en.wikipedia.org/wiki/Incircle_and_excircles_of_a_triangle
549 # 𝗞nown: coordinates of each corner of the triangle
550 # 𝗠ethod: intersection of appropriate angles of the triangles
551 #-------------------------------------------------------------------------------
552  
553 sub exCircles(&$$$$$$)
554 19 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine exCircles: called CC=6 SCAR=18.4
Pod documented
555 19 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 19 0 19
556 19 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 19 19
Condition33%3/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0019
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
1900
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
1900
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table14%1/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
557  
558 19 ▶ my @c = &intersectionLines(sub{@_}, # Centres
Subroutine __ANON__: called CC=1 SCAR=0.0
559 19 ▶ (bisectAnAngle {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪),
Subroutine __ANON__: called CC=1 SCAR=0.0
560 19 ▶ (bisectAnAngle {@_} $𝘅, $𝘆, $𝕩, $𝕪, 2*$𝘅 - $x, 2*$𝘆 - $y));
Subroutine __ANON__: called CC=1 SCAR=0.0
561  
562 19 ▶ my @𝗰 = &intersectionLines(sub{@_},
Subroutine __ANON__: called CC=1 SCAR=0.0
563 19 ▶ (bisectAnAngle {@_} $𝘅, $𝘆, $𝕩, $𝕪, $x, $y),
Subroutine __ANON__: called CC=1 SCAR=0.0
564 19 ▶ (bisectAnAngle {@_} $𝕩, $𝕪, $x, $y, 2*$𝕩 - $𝘅, 2*$𝕪 - $𝘆));
Subroutine __ANON__: called CC=1 SCAR=0.0
565  
566 19 ▶ my @𝕔 = &intersectionLines(sub{@_},
Subroutine __ANON__: called CC=1 SCAR=0.0
567 19 ▶ (bisectAnAngle {@_} $𝕩, $𝕪, $x, $y, $𝘅, $𝘆),
Subroutine __ANON__: called CC=1 SCAR=0.0
568 19 ▶ (bisectAnAngle {@_} $x, $y, $𝘅, $𝘆, 2*$x - $𝕩, 2*$y - $𝕪));
Subroutine __ANON__: called CC=1 SCAR=0.0
569  
570 19 ▶ my @r = (&unsignedDistanceFromLineToPoint(sub {@_}, $x, $y, $𝘅, $𝘆, @c),
Subroutine __ANON__: called CC=1 SCAR=0.0
571 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝘅, $𝘆, $𝕩, $𝕪, @c),
Subroutine __ANON__: called CC=1 SCAR=0.0
572 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝕩, $𝕪, $x, $y, @c));
Subroutine __ANON__: called CC=1 SCAR=0.0
573  
574 19 ▶ my @𝗿 = (&unsignedDistanceFromLineToPoint(sub {@_}, $x, $y, $𝘅, $𝘆, @𝗰),
Subroutine __ANON__: called CC=1 SCAR=0.0
575 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝘅, $𝘆, $𝕩, $𝕪, @𝗰),
Subroutine __ANON__: called CC=1 SCAR=0.0
576 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝕩, $𝕪, $x, $y, @𝗰));
Subroutine __ANON__: called CC=1 SCAR=0.0
577  
578 19 ▶ my @𝕣 = (&unsignedDistanceFromLineToPoint(sub {@_}, $x, $y, $𝘅, $𝘆, @𝕔),
Subroutine __ANON__: called CC=1 SCAR=0.0
579 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝘅, $𝘆, $𝕩, $𝕪, @𝕔),
Subroutine __ANON__: called CC=1 SCAR=0.0
580 19 ▶ &unsignedDistanceFromLineToPoint(sub {@_}, $𝕩, $𝕪, $x, $y, @𝕔));
Subroutine __ANON__: called CC=1 SCAR=0.0
581 19 ([@c, @r], [@𝗰, @𝗿], [@𝕔, @𝕣]) # For each circle, the centre followed by the radii estimates
582 }
583  
584 #-------------------------------------------------------------------------------
585 # 𝗖entroid: intersection of lines between corners and mid points of opposite sides
586 # 𝗙ind: coordinates of centroid
587 # 𝗞nown: coordinates of each corner of the triangle
588 #-------------------------------------------------------------------------------
589  
590 sub centroid(&$$$$$$)
591 22 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine centroid: called CC=6 SCAR=22.1
Pod documented
592 22 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 22 0 22
593 22 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 22 22
Condition33%3/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0022
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
2200
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
2200
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table14%1/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
594  
595 22 ▶ &intersectionLines(sub{&$sub(@_)},
Subroutine __ANON__: called CC=1 SCAR=0.0
596 22 $x, $y, midPoint($𝘅, $𝘆, $𝕩, $𝕪),
597 $𝘅, $𝘆, midPoint($𝕩, $𝕪, $x, $y));
598 }
599  
600 #-------------------------------------------------------------------------------
601 # 𝗢rthocentre: intersection of altitudes
602 # 𝗙ind: coordinates of orthocentre
603 # 𝗞nown: coordinates of each corner of the triangle
604 #-------------------------------------------------------------------------------
605  
606 sub orthoCentre(&$$$$$$)
607 22 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine orthoCentre: called CC=6 SCAR=21.2
Pod documented
608 22 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 22 0 22
609 22 ▶ (near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪)) and confess "Corners are too close!";
Branch: 1 branch
BranchTrueFalseTotal
&near($x, $𝘅) && &near($y, $𝘆) || &near($𝘅, $𝕩) && &near($𝘆, $𝕪) and confess("Corners are too close!") 0 22 22
Condition33%3/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
0022
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
2200
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
2200
MC/DC0%0/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table14%1/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
610  
611 22 ▶ &intersectionLines(sub{&$sub(@_)},
Subroutine __ANON__: called CC=1 SCAR=0.0
612 22 ▶ $x, $y, (intersectionLinePoint {@_} $𝘅, $𝘆, $𝕩, $𝕪, $x, $y),
Subroutine __ANON__: called CC=1 SCAR=0.0
613 22 ▶ $𝘅, $𝘆, (intersectionLinePoint {@_} $𝕩, $𝕪, $x, $y, $𝘅, $𝘆));
Subroutine __ANON__: called CC=1 SCAR=0.0
614 }
615  
616 #-------------------------------------------------------------------------------
617 # 𝗔rea of a triangle
618 # 𝗞nown: coordinates of each corner of the triangle
619 # 𝗙ind: area
620 # 𝗠ethod: height of one corner from line through other two corners
621 #-------------------------------------------------------------------------------
622  
623 sub areaOfTriangle(&$$$$$$)
624 125 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Subroutine to process results, coordinates of corners
Subroutine areaOfTriangle: called CC=6 SCAR=18.2
Pod documented
625 125 ▶ @_ == 7 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 7 or confess("Wrong number of parameters") 125 0 125
626 125 ▶ return &$sub(0) if near($x, $𝘅) && near($y, $𝘆) or near($𝘅, $𝕩) && near($𝘆, $𝕪); # A pair of corners are close, so the area of the triangle must be zero
Branch: 1 branch
BranchTrueFalseTotal
if &near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪) 12 113 125
Condition77%7/9
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
l!l&&r!l&&!r
120113
&near($x, $𝘅) and &near($y, $𝘆)
!ll&&!rl&&r
108512
&near($𝘅, $𝕩) and &near($𝘆, $𝕪)
!ll&&!rl&&r
103100
MC/DC50%2/4
&near($x, $𝘅) and &near($y, $𝘆) or &near($𝘅, $𝕩) and &near($𝘆, $𝕪)
&near($x, $𝘅) &near($y, $𝘆) &near($𝘅, $𝕩) &near($𝘆, $𝕪)
Truth table71%5/7
A and B or C and D
A= &near($x, $𝘅)B= &near($y, $𝘆)C= &near($𝘅, $𝕩)D= &near($𝘆, $𝕪)
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
627 113 ▶ my ($d) = unsignedDistanceFromLineToPoint(sub {@_}, $𝘅, $𝘆, $𝕩, $𝕪, $x, $y); # Distance for first corner from opposite line
Subroutine __ANON__: called CC=1 SCAR=0.0
628 113 &$sub($d * vectorLength($𝘅, $𝘆, $𝕩, $𝕪)/2) # Area = half base * height
629 }
630  
631 #-------------------------------------------------------------------------------
632 # 𝗔rea of a polygon
633 # 𝗞nown: coordinates of each corner=vertex of the polygon
634 # 𝗙ind: area
635 # 𝗠ethod: divide the polygon into triangles which all share the first vertex
636 #-------------------------------------------------------------------------------
637  
638 sub areaOfPolygon(&@)
639 33 ▶ {my ($sub, $x, $y, $𝘅, $𝘆, $𝕩, $𝕪, @vertices) = @_; # Subroutine to process results, coordinates of vertices
Subroutine areaOfPolygon: called CC=2 SCAR=6.9
Pod documented
640 33 ▶ my ($area) = areaOfTriangle {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Area of first triangle
Subroutine __ANON__: called CC=1 SCAR=0.0
641 33 ▶ for(;scalar @vertices;) # Each subsequent triangle
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @vertices) 26 33 59
642 26 {($𝘅, $𝘆) = ($𝕩, $𝕪); # Move up one vertex at a time
643 26 ($𝕩, $𝕪) = splice @vertices, 0, 2; # Remove one vertex
644 26 ▶ my ($a) = areaOfTriangle {@_} $x, $y, $𝘅, $𝘆, $𝕩, $𝕪; # Area of latest triangle
Subroutine __ANON__: called CC=1 SCAR=0.0
645 26 $area += $a; # Sum areas
646 }
647 33 &$sub($area) # Area of polygon
648 }
649  
650 #-------------------------------------------------------------------------------
651 # 𝗦mallest positive angle made at the intersection of two lines, expressed in degrees
652 # 𝗞nown: coordinates of start and end of each line segment
653 # 𝗙ind: smallest angle between the two lines or zero if they do not intersect
654 # 𝗠ethod: use dot product
655 #-------------------------------------------------------------------------------
656  
657 sub smallestPositiveAngleBetweenTwoLines($$$$$$$$)
658 6 ▶ {my ($x, $y, $𝘅, $𝘆, $X, $Y, $𝗫, $𝗬) = @_; # Start and end coordinates of two line segments
Subroutine smallestPositiveAngleBetweenTwoLines: called CC=2 SCAR=6.9
Pod documented
659 6 my ($𝕩, $𝕪) = ($𝘅 - $x, $𝘆 - $y); # Vector along first line segment
660 6 my ($𝕏, $𝕐) = ($𝗫 - $X, $𝗬 - $Y); # Vector along second line segment
661 6 my $r = acos(($𝕩*$𝕏 + $𝕪*$𝕐) / sqrt(($𝕩*$𝕩+$𝕪*$𝕪) * ($𝕏*$𝕏 + $𝕐*$𝕐))); # Result in radians
662 6 my $𝗿 = abs(180 * $r / 𝝿()); # Result in positive degrees
663 6 ▶ $𝗿 > 90 ? 180 - $𝗿 : $𝗿 # Smallest angle between two lines
Branch: 1 branch
BranchTrueFalseTotal
$𝗿 > 90 ? : 3 3 6
664 }
665  
666 #-------------------------------------------------------------------------------
667 # 𝗜s a triangle equilateral?
668 # 𝗞nown: coordinates of each corner=vertex of the triangle
669 # 𝗠ethod: compare lengths of sides
670 #-------------------------------------------------------------------------------
671  
672 sub isEquilateralTriangle(@)
673 1 ▶ {my ($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Coordinates of vertices
Subroutine isEquilateralTriangle: called CC=3 SCAR=11.4
Pod documented
674 1 ▶ @_ == 6 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 6 or confess("Wrong number of parameters") 1 0 1
675 1 my ($d, $𝗱, $𝕕) = &lengthsOfTheSidesOfAPolygon(@_); # Lengths of sides
676 1 ▶ near($d, $𝗱) && near($𝗱, $𝕕) # Equal sided?
Branch: 1 branch
BranchTrueFalseTotal
&near($d, $𝗱) and &near($𝗱, $𝕕) 1 0 1
677 }
678  
679 #-------------------------------------------------------------------------------
680 # 𝗜s a triangle isosceles
681 # 𝗞nown: coordinates of each corner=vertex of the triangle
682 # 𝗠ethod: compare lengths of sides
683 #-------------------------------------------------------------------------------
684  
685 sub isIsoscelesTriangle(@)
686 2 ▶ {my ($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Coordinates of vertices
Subroutine isIsoscelesTriangle: called CC=4 SCAR=14.6
Pod documented
687 2 ▶ @_ == 6 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 6 or confess("Wrong number of parameters") 2 0 2
688 2 my ($d, $𝗱, $𝕕) = &lengthsOfTheSidesOfAPolygon(@_); # Lengths of sides
689 2 ▶ near($d, $𝗱) || near($𝗱, $𝕕) || near($d, $𝕕) # Two sides with equal lengths
Branch: 1 branch
BranchTrueFalseTotal
&near($d, $𝗱) or &near($𝗱, $𝕕) or &near($d, $𝕕) 2 0 2
Condition66%2/3
&near($d, $𝗱) or &near($𝗱, $𝕕)
l!l&&r!l&&!r
110
MC/DC0%0/2
&near($d, $𝗱) or &near($𝗱, $𝕕)
&near($d, $𝗱) &near($𝗱, $𝕕)
Truth table66%2/3
A or B
A= &near($d, $𝗱)B= &near($𝗱, $𝕕)
ABresult
1X1
011
000
690 }
691  
692 #-------------------------------------------------------------------------------
693 # 𝗜s a right angled triangle
694 # 𝗞nown: coordinates of each corner=vertex of the triangle
695 # 𝗠ethod: pythagoras on sides
696 #-------------------------------------------------------------------------------
697  
698 sub isRightAngledTriangle(@)
699 1 ▶ {my ($x, $y, $𝘅, $𝘆, $𝕩, $𝕪) = @_; # Coordinates of vertices
Subroutine isRightAngledTriangle: called CC=4 SCAR=15.6
Pod documented
700 1 ▶ @_ == 6 or confess "Wrong number of parameters";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 6 or confess("Wrong number of parameters") 1 0 1
701 1 my ($d, $𝗱, $𝕕) = &lengthsOfTheSidesOfAPolygon(@_); # Lengths of sides
702 1 ▶ near($d**2,$𝗱**2+$𝕕**2)||near($𝗱**2,$d**2+$𝕕**2) || near($𝕕**2,$d**2+$𝗱**2) # Pythagoras
Branch: 1 branch
BranchTrueFalseTotal
&near($d ** 2, $𝗱 ** 2 + $𝕕 ** 2) or &near($𝗱 ** 2, $d ** 2 + $𝕕 ** 2) or &near($𝕕 ** 2, $d ** 2 + $𝗱 ** 2) 1 0 1
Condition33%1/3
&near($d ** 2, $𝗱 ** 2 + $𝕕 ** 2) or &near($𝗱 ** 2, $d ** 2 + $𝕕 ** 2)
l!l&&r!l&&!r
010
MC/DC0%0/2
&near($d ** 2, $𝗱 ** 2 + $𝕕 ** 2) or &near($𝗱 ** 2, $d ** 2 + $𝕕 ** 2)
&near($d ** 2, $𝗱 ** 2 + $𝕕 ** 2) &near($𝗱 ** 2, $d ** 2 + $𝕕 ** 2)
Truth table33%1/3
A or B
A= &near($d ** 2, $𝗱 ** 2 + $𝕕 ** 2)B= &near($𝗱 ** 2, $d ** 2 + $𝕕 ** 2)
ABresult
1X1
011
000
703 }
704  
705 #-------------------------------------------------------------------------------
706 # 𝗘xport details
707 #-------------------------------------------------------------------------------
708  
709 1 require 5;
710 1 require Exporter;
711  
712 1 ▶use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
713  
714 1 @ISA = qw(Exporter);
715  
716 1 @EXPORT = qw(exCircles intersectionCircles intersectionCirclesArea
717 intersectionCircleLine intersectionCircleLineArea intersectionLines
718 intersectionLinePoint circumCircle circumCentre circleInscribedInTriangle
719 ninePointCircle areaOfTriangle areaOfPolygon orthoCentre centroid
720 isEquilateralTriangle isIsoscelesTriangle isRightAngledTriangle);
721  
722 1 @EXPORT_OK = qw(midPoint near near2 near3 near4 rotate90CW rotate90CCW
723 rotate90AroundMidPoint vectorLength 𝝿 lengthsOfTheSidesOfAPolygon
724 threeCollinearPoints smallestPositiveAngleBetweenTwoLines);
725  
726 1 $EXPORT_TAGS{all} = [@EXPORT, @EXPORT_OK];
727  
728 =head1 Description
729  
730 Find the points at which circles and lines intersect to test geometric
731 intuition.
732  
733 Fast, fun and easy to use these functions are written in 100% Pure Perl.
734  
735 =head2 areaOfTriangle 𝘀𝘂𝗯 triangle
736  
737 Calls 𝘀𝘂𝗯($a) where $a is the area of the specified triangle:
738  
739 A triangle is specified by supplying a list of six numbers:
740  
741 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
742  
743 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
744 triangle.
745  
746 =head2 areaOfPolygon 𝘀𝘂𝗯 points...
747  
748 Calls 𝘀𝘂𝗯($a) where $a is the area of the polygon with vertices specified by
749 the points.
750  
751 A point is specified by supplying a list of two numbers:
752  
753 (𝘅, 𝘆)
754  
755 =head2 centroid 𝘀𝘂𝗯 triangle
756  
757 Calls 𝘀𝘂𝗯($x,$y) where $x,$y are the coordinates of the centroid of the
758 specified triangle:
759  
760 See: L<https://en.wikipedia.org/wiki/Centroid>
761  
762 A triangle is specified by supplying a list of six numbers:
763  
764 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
765  
766 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
767 triangle.
768  
769 =head2 circumCentre 𝘀𝘂𝗯 triangle
770  
771 Calls 𝘀𝘂𝗯($x,$y,$r) where $x,$y are the coordinates of the centre of the
772 circle drawn through the corners of the specified triangle and $r is its
773 radius:
774  
775 See: L<https://en.wikipedia.org/wiki/Circumscribed_circle>
776  
777 A triangle is specified by supplying a list of six numbers:
778  
779 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
780  
781 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
782 triangle.
783  
784 =head2 circumCircle 𝘀𝘂𝗯 triangle
785  
786 Calls 𝘀𝘂𝗯($x,$y,$r) where $x,$y are the coordinates of the circumcentre of
787 the specified triangle and $r is its radius:
788  
789 See: L<https://en.wikipedia.org/wiki/Circumscribed_circle>
790  
791 A triangle is specified by supplying a list of six numbers:
792  
793 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
794  
795 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
796 triangle.
797  
798 =head2 exCircles 𝘀𝘂𝗯 triangle
799  
800 Calls 𝘀𝘂𝗯([$x,$y,$r]...) where $x,$y are the coordinates of the centre of each
801 ex-circle and $r its radius for the specified triangle:
802  
803 See: L<https://en.wikipedia.org/wiki/Incircle_and_excircles_of_a_triangle>
804  
805 A triangle is specified by supplying a list of six numbers:
806  
807 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
808  
809 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
810 triangle.
811  
812 =head2 circleInscribedInTriangle 𝘀𝘂𝗯 triangle
813  
814 Calls 𝘀𝘂𝗯($x,$y,$r) where $x,$y are the coordinates of the centre of
815 a circle which touches each side of the triangle just once and $r is its radius:
816  
817 See: L<https://en.wikipedia.org/wiki/Incircle_and_excircles_of_a_triangle#Incircle>
818  
819 A triangle is specified by supplying a list of six numbers:
820  
821 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
822  
823 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
824 triangle.
825  
826 =head2 intersectionCircles 𝘀𝘂𝗯 circle1, circle2
827  
828 Find the points at which two circles intersect. Complains if the two circles
829 are identical.
830  
831 𝘀𝘂𝗯 specifies a subroutine to be called with the coordinates of the
832 intersection points if there are any or an empty parameter list if there are
833 no points of intersection.
834  
835 A circle is specified by supplying a list of three numbers:
836  
837 (𝘅, 𝘆, 𝗿)
838  
839 where (𝘅, 𝘆) are the coordinates of the centre of the circle and (𝗿) is its
840 radius.
841  
842 Returns whatever is returned by 𝘀𝘂𝗯.
843  
844 =head2 intersectionCirclesArea 𝘀𝘂𝗯 circle1, circle2
845  
846 Find the area of overlap of two circles expressed as a fraction of the area of
847 the smallest circle. The fractional area is expressed as a number between 0
848 and 1.
849  
850 𝘀𝘂𝗯 specifies a subroutine to be called with the fractional area.
851  
852 A circle is specified by supplying a list of three numbers:
853  
854 (𝘅, 𝘆, 𝗿)
855  
856 where (𝘅, 𝘆) are the coordinates of the centre of the circle and (𝗿) is its
857 radius.
858  
859 Returns whatever is returned by 𝘀𝘂𝗯.
860  
861 =head2 intersectionCircleLine 𝘀𝘂𝗯 circle, line
862  
863 Find the points at which a circle and a line intersect.
864  
865 𝘀𝘂𝗯 specifies a subroutine to be called with the coordinates of the
866 intersection points if there are any or an empty parameter list if there are
867 no points of intersection.
868  
869 A circle is specified by supplying a list of three numbers:
870  
871 (𝘅, 𝘆, 𝗿)
872  
873 where (𝘅, 𝘆) are the coordinates of the centre of the circle and (𝗿) is its
874 radius.
875  
876 A line is specified by supplying a list of four numbers:
877  
878 (x, y, 𝘅, 𝘆)
879  
880 where (x, y) and (𝘅, 𝘆) are the coordinates of two points on the line.
881  
882 Returns whatever is returned by 𝘀𝘂𝗯.
883  
884 =head2 intersectionCircleLineArea 𝘀𝘂𝗯 circle, line
885  
886 Find the fractional area of a circle occupied by a lune produced by an
887 intersecting line. The fractional area is expressed as a number
888 between 0 and 1.
889  
890 𝘀𝘂𝗯 specifies a subroutine to be called with the fractional area.
891  
892 A circle is specified by supplying a list of three numbers:
893  
894 (𝘅, 𝘆, 𝗿)
895  
896 where (𝘅, 𝘆) are the coordinates of the centre of the circle and (𝗿) is its
897 radius.
898  
899 A line is specified by supplying a list of four numbers:
900  
901 (x, y, 𝘅, 𝘆)
902  
903 where (x, y) and (𝘅, 𝘆) are the coordinates of two points on the line.
904  
905 Returns whatever is returned by 𝘀𝘂𝗯.
906  
907 =head2 intersectionLines 𝘀𝘂𝗯 line1, line2
908  
909 Finds the point at which two lines intersect.
910  
911 𝘀𝘂𝗯 specifies a subroutine to be called with the coordinates of the
912 intersection point or an empty parameter list if the two lines do not
913 intersect.
914  
915 Complains if the two lines are collinear.
916  
917 A line is specified by supplying a list of four numbers:
918  
919 (x, y, 𝘅, 𝘆)
920  
921 where (x, y) and (𝘅, 𝘆) are the coordinates of two points on the line.
922  
923 Returns whatever is returned by 𝘀𝘂𝗯.
924  
925 =head2 intersectionLinePoint 𝘀𝘂𝗯 line, point
926  
927 Find the point on a line closest to a specified point.
928  
929 𝘀𝘂𝗯 specifies a subroutine to be called with the coordinates of the
930 intersection points if there are any.
931  
932 A line is specified by supplying a list of four numbers:
933  
934 (x, y, 𝘅, 𝘆)
935  
936 where (x, y) and (𝘅, 𝘆) are the coordinates of two points on the line.
937  
938 A point is specified by supplying a list of two numbers:
939  
940 (𝘅, 𝘆)
941  
942 where (𝘅, 𝘆) are the coordinates of the point.
943  
944 Returns whatever is returned by 𝘀𝘂𝗯.
945  
946 =head2 isEquilateralTriangle triangle
947  
948 Return true if the specified triangle is close to being equilateral within the
949 definition of nearness.
950  
951 A triangle is specified by supplying a list of six numbers:
952  
953 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
954  
955 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
956 triangle.
957  
958 =head2 isIsoscelesTriangle triangle
959  
960 Return true if the specified triangle is close to being isosceles within the
961 definition of nearness.
962  
963 A triangle is specified by supplying a list of six numbers:
964  
965 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
966  
967 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
968 triangle.
969  
970 =head2 isRightAngledTriangle triangle
971  
972 Return true if the specified triangle is close to being right angled within
973 the definition of nearness.
974  
975 A triangle is specified by supplying a list of six numbers:
976  
977 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
978  
979 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
980 triangle.
981  
982 =head2 ninePointCircle 𝘀𝘂𝗯 triangle
983  
984 Calls 𝘀𝘂𝗯($x,$y,$r) where $x,$y are the coordinates of the centre of the
985 circle drawn through the midpoints of each side of the specified triangle and
986 $r is its radius which gives the nine point circle:
987  
988 See: L<https://en.wikipedia.org/wiki/Nine-point_circle>
989  
990 A triangle is specified by supplying a list of six numbers:
991  
992 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
993  
994 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
995 triangle.
996  
997 =head2 orthoCentre 𝘀𝘂𝗯 triangle
998  
999 Calls 𝘀𝘂𝗯($x,$y) where $x,$y are the coordinates of the orthocentre of the
1000 specified triangle:
1001  
1002 See: L<https://en.wikipedia.org/wiki/Altitude_%28triangle%29>
1003  
1004 A triangle is specified by supplying a list of six numbers:
1005  
1006 (x, y, 𝘅, 𝘆, 𝕩, 𝕪)
1007  
1008 where (x, y), (𝘅, 𝘆) and (𝕩, 𝕪) are the coordinates of the vertices of the
1009 triangle.
1010  
1011 =head2 $Math::Intersection::Circle::Line::near
1012  
1013 As a finite computer cannot represent an infinite plane of points it is
1014 necessary to make the plane discrete by merging points closer than the
1015 distance contained in this variable, which is set by default to 1e-6.
1016  
1017 =head1 Exports
1018  
1019 The following functions are exported by default:
1020  
1021 =over
1022  
1023 =item C<areaOfPolygon()>
1024  
1025 =item C<areaOfTriangle()>
1026  
1027 =item C<centroid()>
1028  
1029 =item C<circumCentre()>
1030  
1031 =item C<circumCircle()>
1032  
1033 =item C<circleInscribedInTriangle()>
1034  
1035 =item C<circleThroughMidPointsOfTriangle()>
1036  
1037 =item C<exCircles()>
1038  
1039 =item C<intersectionCircleLine()>
1040  
1041 =item C<intersectionCircleLineArea()>
1042  
1043 =item C<intersectionCircles()>
1044  
1045 =item C<intersectionCircles()>
1046  
1047 =item C<intersectionCirclesArea()>
1048  
1049 =item C<intersectionLines()>
1050  
1051 =item C<intersectionLinePoint()>
1052  
1053 =item C<isEquilateralTriangle()>
1054  
1055 =item C<isIsoscelesTriangle()>
1056  
1057 =item C<isRightAngledTriangle()>
1058  
1059 =item C<orthoCentre()>
1060  
1061 =back
1062  
1063 Optionally some useful helper functions can also be exported either by
1064 specifying the tag :𝗮𝗹𝗹 or by naming the required functions individually:
1065  
1066 =over
1067  
1068 =item C<acos()>
1069  
1070 =item C<lengthsOfTheSidesOfAPolygon()>
1071  
1072 =item C<midPoint()>
1073  
1074 =item C<midPoint()>
1075  
1076 =item C<near()>
1077  
1078 =item C<near2()>
1079  
1080 =item C<near3()>
1081  
1082 =item C<near4()>
1083  
1084 =item C<rotate90CW()>
1085  
1086 =item C<rotate90CCW()>
1087  
1088 =item C<rotate90AroundMidPoint()>
1089  
1090 =item C<smallestPositiveAngleBetweenTwoLines()>
1091  
1092 =item C<threeCollinearPoints()>
1093  
1094 =item C<vectorLength()>
1095  
1096 =item C<𝝿()>
1097  
1098 =back
1099  
1100 =head1 Changes
1101  
1102 1.003 Sun 30 Aug 2015 - Started Geometry app
1103 1.005 Sun 20 Dec 2015 - Still going!
1104 1.006 Sat 02 Jan 2016 - Euler's line divided into 6 equal pieces
1105 1.007 Sat 02 Jan 2016 - [rt.cpan.org #110849] Test suite fails with uselongdouble
1106 1.008 Sun 03 Jan 2016 - [rt.cpan.org #110849] Removed dump
1107  
1108 =cut
1109  
1110 1 $VERSION = '1.008';
1111  
1112 =pod
1113  
1114 =head1 Installation
1115  
1116 Standard Module::Build process for building and installing modules:
1117  
1118 perl Build.PL
1119 ./Build
1120 ./Build test
1121 ./Build install
1122  
1123 Or, if you're on a platform (like DOS or Windows) that doesn't require
1124 the "./" notation, you can do this:
1125  
1126 perl Build.PL
1127 Build
1128 Build test
1129 Build install
1130  
1131 =head1 Author
1132  
1133 Philip R Brenan at gmail dot com
1134  
1135 http://www.appaapps.com
1136  
1137 =head1 Copyright
1138  
1139 Copyright (c) 2016 Philip R Brenan.
1140  
1141 This module is free software. It may be used, redistributed and/or
1142 modified under the same terms as Perl itself.
1143  
1144 =cut
↑ Summary