Centre and radius of a circle passing through 3 points in a plane: Difference between revisions
Content added Content deleted
(julia example) |
Thundergnat (talk | contribs) (→{{header|Raku}}: Add a Raku example) |
||
Line 402: | Line 402: | ||
Centre = 18.97851566, 16.2654108, radius = 14.708624 |
Centre = 18.97851566, 16.2654108, radius = 14.708624 |
||
</pre> |
</pre> |
||
=={{header|Raku}}== |
|||
Don't bother defining all the intermediate variables. |
|||
<syntaxhighlight lang="raku" line>sub circle( (\x, \y), (\X, \Y), (\Х, \У) ) { |
|||
:center( |
|||
my $cx = ((x² + y²) × (У - Y) + (X² + Y²) × (y - У) + (Х² + У²) × (Y - y)) / |
|||
(x × (У - Y) + X × (y - У) + Х × (Y - y)) / 2, |
|||
my $cy = ((x² + y²) × (Х - X) + (X² + Y²) × (x - Х) + (Х² + У²) × (X - x)) / |
|||
(y × (Х - X) + Y × (x - Х) + У × (X - x)) / 2 |
|||
), |
|||
radius => (($cx - x)² + ($cy - y)²).sqrt |
|||
} |
|||
say circle (22.83,2.07), (14.39,30.24), (33.65,17.31);</syntaxhighlight> |
|||
{{out}} |
|||
<pre>(center => (18.97851566 16.2654108) radius => 14.70862397833418)</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |