mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-25 13:59:04 +02:00
refactor
This commit is contained in:
@@ -11,17 +11,10 @@ use <util/find_index.scad>;
|
|||||||
function cc_center(cc) = cc[0];
|
function cc_center(cc) = cc[0];
|
||||||
function cc_rr(cc) = cc[2];
|
function cc_rr(cc) = cc[2];
|
||||||
|
|
||||||
function delaunay_init(points) =
|
function delaunay_init(center, width, height) =
|
||||||
let(
|
let(
|
||||||
xs = [for(p = points) p[0]],
|
halfW = width * 0.5,
|
||||||
ys = [for(p = points) p[1]],
|
halfH = height * 0.5,
|
||||||
max_x = max(xs),
|
|
||||||
min_x = min(xs),
|
|
||||||
max_y = max(ys),
|
|
||||||
min_y = min(ys),
|
|
||||||
center = [max_x + min_x, max_y + min_y] / 2,
|
|
||||||
halfW = abs(max_x - center[0]) * 2,
|
|
||||||
halfH = abs(max_y - center[1]) * 2,
|
|
||||||
coords = [
|
coords = [
|
||||||
center + [-halfW, -halfH],
|
center + [-halfW, -halfH],
|
||||||
center + [-halfW, halfH],
|
center + [-halfW, halfH],
|
||||||
|
@@ -2,7 +2,18 @@ use <experimental/_impl/_tri_delaunay_impl.scad>;
|
|||||||
|
|
||||||
// ret: "TRI_SHAPES", "TRI_INDICES", "DELAUNAY"
|
// ret: "TRI_SHAPES", "TRI_INDICES", "DELAUNAY"
|
||||||
function tri_delaunay(points, ret = "TRI_SHAPES") =
|
function tri_delaunay(points, ret = "TRI_SHAPES") =
|
||||||
let(d = _tri_delaunay(delaunay_init(points), points, len(points)))
|
let(
|
||||||
|
xs = [for(p = points) p[0]],
|
||||||
|
ys = [for(p = points) p[1]],
|
||||||
|
max_x = max(xs),
|
||||||
|
min_x = min(xs),
|
||||||
|
max_y = max(ys),
|
||||||
|
min_y = min(ys),
|
||||||
|
center = [max_x + min_x, max_y + min_y] / 2,
|
||||||
|
width = abs(max_x - center[0]) * 4,
|
||||||
|
height = abs(max_y - center[1]) * 4,
|
||||||
|
d = _tri_delaunay(delaunay_init(center, width, height), points, len(points))
|
||||||
|
)
|
||||||
ret == "TRI_SHAPES" ? tri_delaunay_shapes(d) :
|
ret == "TRI_SHAPES" ? tri_delaunay_shapes(d) :
|
||||||
ret == "TRI_INDICES" ? tri_delaunay_indices(d) :
|
ret == "TRI_INDICES" ? tri_delaunay_indices(d) :
|
||||||
d; // "DELAUNAY": [coords(list), triangles(hashmap), circles(hashmap)]
|
d; // "DELAUNAY": [coords(list), triangles(hashmap), circles(hashmap)]
|
Reference in New Issue
Block a user