From 32ff742d0e98c133b32ce4bff0fb59e4991ade10 Mon Sep 17 00:00:00 2001 From: Alex Matulich Date: Sun, 20 Apr 2025 17:45:25 -0700 Subject: [PATCH 1/4] fix bunching in vnf_tri_array --- vnf.scad | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/vnf.scad b/vnf.scad index 3b512602..d08f875a 100644 --- a/vnf.scad +++ b/vnf.scad @@ -311,7 +311,7 @@ function vnf_vertex_array( texture, tex_reps, tex_size, tex_samples, tex_inset=false, tex_rot=0, tex_depth=1, tex_extra, tex_skip, sidecaps,sidecap1,sidecap2, normals ) = - assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2"])) + assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2","diagnormals"])) assert(is_matrix(points[0], n=3),"\nPoint array has the wrong shape or points are not 3d.") assert(is_consistent(points), "\nNon-rectangular or invalid point array.") assert(is_bool(triangulate)) @@ -347,6 +347,7 @@ function vnf_vertex_array( ) mean([pts[i1], pts[i2], pts[i3], pts[i4]]) ], + surfnorms = style=="diagnormals" ? surface_normals(points, row_wrap=row_wrap, col_wrap=col_wrap) : [], allfaces = [ if (cap1) count(cols,reverse=!reverse), if (cap2) count(cols,(rows-1)*cols, reverse=reverse), @@ -401,6 +402,16 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]] ) concavefaces + : style=="diagnormals"? + let( + ang13 = vector_angle(surfnorms[r][c],surfnorms[(r+1)%rows][(c+1)%cols]), + ang24 = vector_angle(surfnorms[(r+1)%rows][c],surfnorms[r][(c+1)%cols]), + smallang = ang24=n1 && t2>=n2 ? trilist : - _lofttri(p1, p2, i1offset, i2offset, n1, n2, reverse, concat(trilist, [triangle]), d12=n1?i1:t1) : i1, userow==2 ? (t2>=n2?i2:t2) : i2, tc1, tc2, trimax) : // equal row lengths let(n=n1, i=i1, @@ -606,7 +628,7 @@ function _lofttri(p1, p2, i1offset, i2offset, n1, n2, reverse=false, trilist=[], [i2offset+t, i1offset+t, d12=n ? trilist : - _lofttri(p1, p2, i1offset, i2offset, n, n, reverse, concat(trilist, [triangle1, triangle2]), t, t); + _lofttri(p1, p2, i1offset, i2offset, n, n, reverse, concat(trilist, [triangle1, triangle2]), t, t, 0,0,trimax); // Function: vnf_join() From 8d926f93307e542084fb336b667d62c4bd5caba7 Mon Sep 17 00:00:00 2001 From: Alex Matulich Date: Mon, 21 Apr 2025 14:54:47 -0700 Subject: [PATCH 2/4] fix bunching in vnf_tri_array, added example --- vnf.scad | 72 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/vnf.scad b/vnf.scad index 907b533a..0817f407 100644 --- a/vnf.scad +++ b/vnf.scad @@ -330,7 +330,7 @@ function vnf_vertex_array( texture, tex_reps, tex_size, tex_samples, tex_inset=false, tex_rot=0, tex_scaling="default", tex_depth=1, tex_extra, tex_skip, sidecaps,sidecap1,sidecap2, normals ) = - assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2","diagnormals"])) + assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2"])) assert(is_matrix(points[0], n=3),"\nPoint array has the wrong shape or points are not 3d.") assert(is_consistent(points), "\nNon-rectangular or invalid point array.") assert(is_bool(triangulate)) @@ -366,7 +366,6 @@ function vnf_vertex_array( ) mean([pts[i1], pts[i2], pts[i3], pts[i4]]) ], - surfnorms = style=="diagnormals" ? surface_normals(points, row_wrap=row_wrap, col_wrap=col_wrap) : [], allfaces = [ if (cap1) count(cols,reverse=!reverse), if (cap2) count(cols,(rows-1)*cols, reverse=reverse), @@ -421,16 +420,6 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]] ) concavefaces - : style=="diagnormals"? - let( - ang13 = vector_angle(surfnorms[r][c],surfnorms[(r+1)%rows][(c+1)%cols]), - ang24 = vector_angle(surfnorms[(r+1)%rows][c],surfnorms[r][(c+1)%cols]), - smallang = ang24 Date: Mon, 21 Apr 2025 15:02:16 -0700 Subject: [PATCH 3/4] Corrected docsgen example parameter --- vnf.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnf.scad b/vnf.scad index 0817f407..da610755 100644 --- a/vnf.scad +++ b/vnf.scad @@ -519,7 +519,7 @@ function vnf_vertex_array( // vnf = vnf_tri_array(pts); // vnf_wireframe(vnf,width=0.1); // color("red")move_copies(flatten(pts)) sphere(r=.15,$fn=9); -// Example(3D,Med,NoAxes,ShowEdges=true,VPR=[29,0,341],VPD=45,VPT=[11,5,2]): The default parameter `limit_bunching=true` prevents too many triangles from sharing a single vertex in one row, if several points of one row happen to be closest to a single point on another row. In the left figure, `limit_bunching=false`, causing an endpoint on each row to get many triangles from the other row, because the algorithm seeks the shortest triangle leg distance once the first two points of each row are connected. This doesn't happen if both rows are the same length. The figure on the right uses the default `limit_bunching=true`, forcing the triangulation to stop adding too many triangles to the same vertex. +// Example(3D,Med,NoAxes,Edges,VPR=[29,0,341],VPD=45,VPT=[11,5,2]): The default parameter `limit_bunching=true` prevents too many triangles from sharing a single vertex in one row, if several points of one row happen to be closest to a single point on another row. In the left figure, `limit_bunching=false`, causing an endpoint on each row to get many triangles from the other row, because the algorithm seeks the shortest triangle leg distance once the first two points of each row are connected. This doesn't happen if both rows are the same length. The figure on the right uses the default `limit_bunching=true`, forcing the triangulation to stop adding too many triangles to the same vertex. // pts = [ // [[5,0,0], [4,0,1.4], [3,0,2], [2,0,1.4], [1,0,0]], // [[14,10,0], [12,9,5], [9,8,7], [6,7,7], [3,6,5], [0,5,0]] From 949f6bbf5957fb1c71a398e647401e3f6af13f18 Mon Sep 17 00:00:00 2001 From: Alex Matulich Date: Mon, 21 Apr 2025 16:07:44 -0700 Subject: [PATCH 4/4] spelling --- vnf.scad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnf.scad b/vnf.scad index da610755..632e860d 100644 --- a/vnf.scad +++ b/vnf.scad @@ -443,7 +443,7 @@ function vnf_vertex_array( // See Also: vnf_vertex_array(), vnf_join(), vnf_from_polygons(), vnf_merge_points() // Usage: // vnf = vnf_tri_array(points, [caps=], [cap1=], [cap2=], [reverse=], [col_wrap=], [row_wrap=], [limit_bunching=]) -// vnf_vertex_array(points, [caps=], [cap1=], [cap2=], [reverse=], [col_wrap=], [row_wrap=], [limit_bunching=],...) [ATTACHMENTS]; +// vnf_tri_array(points, [caps=], [cap1=], [cap2=], [reverse=], [col_wrap=], [row_wrap=], [limit_bunching=],...) [ATTACHMENTS]; // Description: // Produces a VNF from an array of points where each row length can differ from the adjacent rows by // any amount. This enables the construction of triangular or even irregular VNF patches. The