From cf9c3121067f28afa69b1d7361e9a36d70436119 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 17 Apr 2021 18:39:45 +0800 Subject: [PATCH] change default value --- src/experimental/demo/tri_delaunay_demo.scad | 18 ++++++------------ src/experimental/tri_delaunay.scad | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/experimental/demo/tri_delaunay_demo.scad b/src/experimental/demo/tri_delaunay_demo.scad index 826af429..5a5e6ef7 100644 --- a/src/experimental/demo/tri_delaunay_demo.scad +++ b/src/experimental/demo/tri_delaunay_demo.scad @@ -3,17 +3,11 @@ use ; points = [for(i = [0:20]) rands(-100, 100, 2)]; -drawTris(tri_delaunay(points)); -module drawTris(pointsOfTriangles) { - #for(t = pointsOfTriangles) { +draw([for(ti = tri_delaunay(points)) [for(i = ti) points[i]]]); +%draw(tri_delaunay(points, ret = "TRI_SHAPES")); + +module draw(pointsOfTriangles) { + for(t = pointsOfTriangles) { hull_polyline2d(concat(t, [t[0]])); } -} - -drawTris2(points, tri_delaunay(points, ret = "TRI_INDICES")); -module drawTris2(points, indices) { - pointsOfTriangles = [for(i = indices) [points[i[0]], points[i[1]], points[i[2]]]]; - %for(t = pointsOfTriangles) { - hull_polyline2d(concat(t, [t[0]]), 2); - } -} +} \ No newline at end of file diff --git a/src/experimental/tri_delaunay.scad b/src/experimental/tri_delaunay.scad index e1446512..d1afa7cb 100644 --- a/src/experimental/tri_delaunay.scad +++ b/src/experimental/tri_delaunay.scad @@ -4,7 +4,7 @@ use ; use ; // ret: "TRI_SHAPES", "TRI_INDICES", "VORONOI_CELLS", "DELAUNAY" -function tri_delaunay(points, ret = "TRI_SHAPES") = +function tri_delaunay(points, ret = "TRI_INDICES") = let( xs = [for(p = points) p[0]], ys = [for(p = points) p[1]], @@ -17,7 +17,7 @@ function tri_delaunay(points, ret = "TRI_SHAPES") = height = abs(max_y - center[1]) * 4, d = _tri_delaunay(delaunay_init(center, width, height), points, len(points)) ) + ret == "TRI_INDICES" ? tri_delaunay_indices(d) : ret == "TRI_SHAPES" ? tri_delaunay_shapes(d) : - ret == "TRI_INDICES" ? tri_delaunay_indices(d) : ret == "VORONOI_CELLS" ? tri_delaunay_voronoi(d) : d; // "DELAUNAY": [coords(list), triangles(hashmap), circles(hashmap)] \ No newline at end of file