mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 10:14:41 +02:00
refactor
This commit is contained in:
@@ -13,10 +13,9 @@ function _triangulate_snipable(shape_pts, u, v, w, n, indices, epsilon = 0.0001)
|
|||||||
let(
|
let(
|
||||||
a = shape_pts[indices[u]],
|
a = shape_pts[indices[u]],
|
||||||
b = shape_pts[indices[v]],
|
b = shape_pts[indices[v]],
|
||||||
c = shape_pts[indices[w]],
|
c = shape_pts[indices[w]]
|
||||||
determinant = cross([b.x - a.x, b.y - a.y], [c.x - a.x, c.y - a.y])
|
|
||||||
)
|
)
|
||||||
epsilon <= determinant && _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices);
|
epsilon <= cross(b - a, c - a) && _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices);
|
||||||
|
|
||||||
function _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p = 0) =
|
function _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p = 0) =
|
||||||
p == n || (
|
p == n || (
|
||||||
|
@@ -15,13 +15,14 @@ function tri_incenter(shape_pts) =
|
|||||||
pc = shape_pts[2],
|
pc = shape_pts[2],
|
||||||
a = norm(pb - pc),
|
a = norm(pb - pc),
|
||||||
b = norm(pc - pa),
|
b = norm(pc - pa),
|
||||||
c = norm(pa - pb)
|
c = norm(pa - pb),
|
||||||
|
abc = [a, b, c]
|
||||||
)
|
)
|
||||||
(len(pa) == 2 ? [
|
(len(pa) == 2 ? [
|
||||||
(a * pa.x + b * pb.x + c * pc.x),
|
abc * [pa.x, pb.x, pc.x],
|
||||||
(a * pa.y + b * pb.y + c * pc.y)
|
abc * [pa.y, pb.y, pc.y]
|
||||||
] : [
|
] : [
|
||||||
(a * pa.x + b * pb.x + c * pc.x),
|
abc * [pa.x, pb.x, pc.x],
|
||||||
(a * pa.y + b * pb.y + c * pc.y),
|
abc * [pa.y, pb.y, pc.y],
|
||||||
(a * pa.z + b * pb.z + c * pc.z)
|
abc * [pa.z, pb.z, pc.z]
|
||||||
]) / (a + b + c);
|
]) / (a + b + c);
|
Reference in New Issue
Block a user