From 2225257f09ef43756042199ade815949284afd9b Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Thu, 8 Apr 2021 17:27:43 -0700 Subject: [PATCH] Tweaks suggested by @adrianVmariano. --- arrays.scad | 2 +- beziers.scad | 4 ++-- math.scad | 2 +- rounding.scad | 2 +- tests/test_geometry.scad | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arrays.scad b/arrays.scad index 45c4281..ac97444 100644 --- a/arrays.scad +++ b/arrays.scad @@ -209,7 +209,7 @@ function list_tail(list, from=1) = // If given a string, explodes it into a list of single letters. // Arguments: // l = The value to expand. -// See Also: scalar_vec3(), force_list(), rangex() +// See Also: scalar_vec3(), force_list() // Example: // l1 = list([3:2:9]); // Returns: [3,5,7,9] // l2 = list([3,4,5]); // Returns: [3,4,5] diff --git a/beziers.scad b/beziers.scad index 1d4b475..bd6a8f0 100644 --- a/beziers.scad +++ b/beziers.scad @@ -507,7 +507,7 @@ function bezier_segment_closest_point(curve, pt, max_err=0.01, u=0, end_u=1) = function bezier_segment_length(curve, start_u=0, end_u=1, max_deflect=0.01) = let( segs = len(curve) * 2, - uvals = lerpn(start_u, end_u, segs), + uvals = lerpn(start_u, end_u, segs+1), path = bezier_points(curve,uvals), defl = max([ for (i=idx(path,e=-3)) let( @@ -721,7 +721,7 @@ function bezier_path(bezier, splinesteps=16, N=3, endpoint=true) = ) [ for (seg = [0:1:segs-1]) each bezier_points(select(bezier, seg*N, (seg+1)*N), [0:step:1-step/2]), - if (endpoint) bezier_path_point(bezier, segs-1, 1, N=N) + if (endpoint) last(bezier) ]; diff --git a/math.scad b/math.scad index bdcd028..43b1347 100644 --- a/math.scad +++ b/math.scad @@ -494,7 +494,7 @@ function rand_int(minval, maxval, N, seed=undef) = function gaussian_rands(mean, stddev, N=1, seed=undef) = assert( is_finite(mean+stddev+N) && (is_undef(seed) || is_finite(seed) ), "Input must be finite numbers.") let(nums = is_undef(seed)? rands(0,1,N*2) : rands(0,1,N*2,seed)) - [for (i = count(N)) mean + stddev*sqrt(-2*ln(nums[i*2]))*cos(360*nums[i*2+1])]; + [for (i = count(N,0,2)) mean + stddev*sqrt(-2*ln(nums[i]))*cos(360*nums[i+1])]; // Function: log_rands() diff --git a/rounding.scad b/rounding.scad index a9f3840..b85a70c 100644 --- a/rounding.scad +++ b/rounding.scad @@ -1996,7 +1996,7 @@ function bezier_patch_degenerate(patch, splinesteps=16, reverse=false) = bpatch = [for(i=[0:1:len(patch[0])-1]) bezier_points(subindex(patch,i), samplepts)], pts = [ [bpatch[0][0]], - for(j=[1:splinesteps]) bezier_points(subindex(bpatch,j), count(rowmax[j]+1)/rowmax[j]) + for(j=[1:splinesteps]) bezier_points(subindex(bpatch,j), lerpn(0,1,rowmax[j]+1)) ], vnf = vnf_tri_array(pts, reverse=reverse) ) [ diff --git a/tests/test_geometry.scad b/tests/test_geometry.scad index 1441f7f..a80894f 100644 --- a/tests/test_geometry.scad +++ b/tests/test_geometry.scad @@ -987,8 +987,8 @@ module test_pointlist_bounds() { module test_closest_point() { - ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463)]; - testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834)]; + ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463+i)]; + testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834+i)]; for (pt = testpts) { pidx = closest_point(pt,ptlist); dists = [for (p=ptlist) norm(pt-p)]; @@ -1000,8 +1000,8 @@ module test_closest_point() { module test_furthest_point() { - ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463)]; - testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834)]; + ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463+i)]; + testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834+i)]; for (pt = testpts) { pidx = furthest_point(pt,ptlist); dists = [for (p=ptlist) norm(pt-p)];