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

use cross to refactor

This commit is contained in:
Justin Lin
2020-02-25 10:07:16 +08:00
parent afffa07f3f
commit 31a150da2b

View File

@@ -9,9 +9,6 @@ function _triangulate_in_triangle(p0, p1, p2, p) =
)
(c0 > 0 && c1 > 0 && c2 > 0) || (c0 < 0 && c1 < 0 && c2 < 0);
function _triangulate_determinant_2x2(matrix) =
matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
function _triangulate_snipable(shape_pts, u, v, w, n, indices, epsilon = 0.0001) =
let(
a = shape_pts[indices[u]],
@@ -23,10 +20,7 @@ function _triangulate_snipable(shape_pts, u, v, w, n, indices, epsilon = 0.0001)
by = b[1],
cx = c[0],
cy = c[1],
determinant = _triangulate_determinant_2x2([
[bx - ax, by - ay],
[cx - ax, cy - ay]
])
determinant = cross([bx - ax, by - ay], [cx - ax, cy - ay])
)
epsilon > determinant ?
false : _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices);