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

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