1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-13 02:04:16 +02:00

add tri_circumcircle

This commit is contained in:
Justin Lin
2020-02-25 10:30:12 +08:00
parent 9a7b5948a0
commit 0eb2e4f974

View File

@@ -0,0 +1,18 @@
function tri_circumcircle(points) =
let(
p0 = points[0],
p1 = points[1],
p2 = points[2],
v0 = p1 - p0,
d0 = (p1 + p0) / 2 * v0,
v1 = p2 - p1,
d1 = (p2 + p1) / 2 * v1,
det = -cross(v0 , v1)
)
det == 0? undef :
let(
x = (d1 * v0[1] - d0 * v1[1]) / det,
y = (d0 * v1[0] - d1 * v0[0]) / det,
r = norm(p0 - [x,y])
)
[[x,y], r];