mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 11:14:17 +02:00
refactor
This commit is contained in:
@@ -87,14 +87,14 @@ function _convex_hull3(pts) =
|
|||||||
leng = len(sorted),
|
leng = len(sorted),
|
||||||
v0 = 0,
|
v0 = 0,
|
||||||
v1 = _fst_v1(sorted, leng, v0 + 1),
|
v1 = _fst_v1(sorted, leng, v0 + 1),
|
||||||
_ = assert(v1 < leng, "common points"),
|
v2 = assert(v1 < leng, "common points")
|
||||||
v2 = _fst_v2(sorted, leng, v1, v1 + 1),
|
_fst_v2(sorted, leng, v1, v1 + 1),
|
||||||
__ = assert(v2 < leng, "collinear points"),
|
n = assert(v2 < leng, "collinear points")
|
||||||
n = cross(sorted[v1] - sorted[v0], sorted[v2] - sorted[v0]),
|
cross(sorted[v1] - sorted[v0], sorted[v2] - sorted[v0]),
|
||||||
v3_d = _fst_v3(sorted, leng, n, 0, v2 + 1),
|
v3_d = _fst_v3(sorted, leng, n, 0, v2 + 1),
|
||||||
v3 = v3_d[0],
|
v3 = v3_d[0],
|
||||||
___ = assert(v3 < leng, "coplanar points"),
|
d = assert(v3 < leng, "coplanar points")
|
||||||
d = v3_d[1],
|
v3_d[1],
|
||||||
fst_tetrahedron = d > 0 ? [
|
fst_tetrahedron = d > 0 ? [
|
||||||
[v1, v0, v2],
|
[v1, v0, v2],
|
||||||
[v0, v1, v3],
|
[v0, v1, v3],
|
||||||
|
@@ -43,10 +43,10 @@ function _bijection_offset_impl(pts, d, epsilon) =
|
|||||||
let(
|
let(
|
||||||
this_edge = offset_es[i],
|
this_edge = offset_es[i],
|
||||||
next_edge = offset_es[i + 1],
|
next_edge = offset_es[i + 1],
|
||||||
p = __line_intersection2(this_edge, next_edge, epsilon),
|
p = __line_intersection2(this_edge, next_edge, epsilon)
|
||||||
// p == p to avoid [nan, nan], because [nan, nan] != [nan, nan],
|
|
||||||
_ = assert(p != [] && p == p, "bijection_offset failed. Parallel or conincident edges found")
|
|
||||||
)
|
)
|
||||||
|
// p == p to avoid [nan, nan], because [nan, nan] != [nan, nan]
|
||||||
|
assert(p != [] && p == p, "bijection_offset failed. Parallel or conincident edges found")
|
||||||
p
|
p
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@@ -3,7 +3,7 @@ function tri_is_ccw(shape_pts) =
|
|||||||
p1 = shape_pts[0],
|
p1 = shape_pts[0],
|
||||||
p2 = shape_pts[1],
|
p2 = shape_pts[1],
|
||||||
p3 = shape_pts[2],
|
p3 = shape_pts[2],
|
||||||
area = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p3[0] - p1[0]) * (p2[1] - p1[1]),
|
area = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p3[0] - p1[0]) * (p2[1] - p1[1])
|
||||||
_ = assert(area != 0, "points are collinear")
|
|
||||||
)
|
)
|
||||||
|
assert(area != 0, "points are collinear")
|
||||||
area > 0;
|
area > 0;
|
Reference in New Issue
Block a user