mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 01:04:07 +02:00
add tri_circumcenter
This commit is contained in:
15
src/triangle/tri_circumcenter.scad
Normal file
15
src/triangle/tri_circumcenter.scad
Normal file
@@ -0,0 +1,15 @@
|
||||
function tri_circumcenter(shape_pts) =
|
||||
let(
|
||||
p0 = shape_pts[0],
|
||||
p1 = shape_pts[1],
|
||||
p2 = shape_pts[2],
|
||||
v0 = p1 - p0,
|
||||
d0 = (p1 + p0) / 2 * v0,
|
||||
v1 = p2 - p1,
|
||||
d1 = (p2 + p1) / 2 * v1,
|
||||
det = -cross(v0 , v1)
|
||||
)
|
||||
det == 0 ? undef : [
|
||||
(d1 * v0[1] - d0 * v1[1]) / det,
|
||||
(d0 * v1[0] - d1 * v0[0]) / det
|
||||
];
|
@@ -1,20 +0,0 @@
|
||||
function tri_circumcircle(shape_pts) =
|
||||
let(
|
||||
p0 = shape_pts[0],
|
||||
p1 = shape_pts[1],
|
||||
p2 = shape_pts[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,
|
||||
center = [x, y],
|
||||
v = p0 - center,
|
||||
r = norm(v)
|
||||
)
|
||||
[center, r];
|
Reference in New Issue
Block a user