Centre and radius of a circle passing through 3 points in a plane: Difference between revisions
Centre and radius of a circle passing through 3 points in a plane (view source)
Revision as of 02:57, 12 April 2024
, 1 month ago→{{header|jq}}: #Julia
(→{{header|jq}}: #Julia) |
|||
Line 441:
=={{header|jq}}==
'''Adapted from [[#
'''Works with jq, the C implementation of jq'''
Line 449:
# Emit {x,y,r} corresponding to the circle through the three points
# specified as [x,y] pairs.
def
def assertEq($p; $q): if ($p - $q)|length < 1e-12 then . else "assertion failed: \($p) != \($q)" | error end;
def ss($a; $
| $p2 as [$x2, $y2]▼
| $p3 as [$e,$f]
| ($
| ($
| ($
| ($
| ($
| ($
|
|
|
| {
# any one of these should do / be nearly identical:
| [ss(.x
| assertEq( $r123|max; $r123|min )
| .r = (($r123
▲ | "Centre is at [\(.x), \(.y)]",
▲demo([22.83, 2.07]; [14.39, 30.24]; [33.65, 17.31])
</syntaxhighlight>
{{output}}
<pre>
Centre
</pre>
|