Circles of given radius through two points: Difference between revisions
Circles of given radius through two points (view source)
Revision as of 04:54, 1 March 2019
, 5 years ago→{{header|Perl}}: correct how results presented
m (→{{header|Visual Basic .Net}}: .Net -> .NET) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: correct how results presented) |
||
Line 2,346:
=={{header|Perl}}==
{{trans|Python}}
<lang perl>
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
$x3 + $d*$dy/$q, $y3 - $d*$dx/$q
}
Line 2,376 ⟶ 2,378:
);
printf "(%.4f, %.4f) and (%.4f, %.4f) with radius %.1f: %s\n", @$_[0..
{{out}}
<pre>(0.1234, 0.9876) and (0.8765, 0.2345) with radius 2.0: (1.8631, 1.9742) and (
(0.0000, 2.0000) and (0.0000, 0.0000) with radius 1.0: (0.0000, 1.0000) and (
(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>
=={{header|Perl 6}}==
|