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:
18
src/experimental/tri_circumcircle.scad
Normal file
18
src/experimental/tri_circumcircle.scad
Normal 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];
|
Reference in New Issue
Block a user