Circles of given radius through two points: Difference between revisions

m
→‎{{header|Perl}}: correct how results presented
m (→‎{{header|Perl}}: correct how results presented)
Line 2,346:
=={{header|Perl}}==
{{trans|Python}}
<lang perl>subuse circles {strict;
 
sub circles {
my ($x1, $y1, $x2, $y2, $r) = @_;
 
Line 2,364 ⟶ 2,366:
# pair of solutions
sprintf '(%.4f, %.4f) and (%.4f, %.4f)',
$x3 - $d*$dy/$q, $y3 + $d*$dx/$q, $r,
$x3 + $d*$dy/$q, $y3 - $d*$dx/$q, $r;
}
 
Line 2,376 ⟶ 2,378:
);
 
printf "(%.4f, %.4f) and (%.4f, %.4f) with radius %.1f: %s\n", @$_[0..34], circles @$_ for @arr;</lang>
{{out}}
<pre>(0.1234, 0.9876) and (0.8765, 0.2345) with radius 2.0: (1.8631, 1.9742) and (2-0.00008632, -0.86327521)
(0.0000, 2.0000) and (0.0000, 0.0000) with radius 1.0: (0.0000, 1.0000) and (10.0000, 01.0000)
(0.1234, 0.9876) and (0.1234, 0.9876) with radius 2.0: Coincident points gives infinite number of circles
(0.1234, 0.9876) and (0.8765, 0.2345) with radius 0.5: Separation of points greater than diameter
(0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.0: Radius is zero</pre>
</pre>
 
=={{header|Perl 6}}==
2,392

edits