Tweaks suggested by @adrianVmariano.

This commit is contained in:
Garth Minette 2021-04-08 17:27:43 -07:00
parent 8a7f184e5c
commit 2225257f09
5 changed files with 9 additions and 9 deletions

View File

@ -209,7 +209,7 @@ function list_tail(list, from=1) =
// If given a string, explodes it into a list of single letters. // If given a string, explodes it into a list of single letters.
// Arguments: // Arguments:
// l = The value to expand. // l = The value to expand.
// See Also: scalar_vec3(), force_list(), rangex() // See Also: scalar_vec3(), force_list()
// Example: // Example:
// l1 = list([3:2:9]); // Returns: [3,5,7,9] // l1 = list([3:2:9]); // Returns: [3,5,7,9]
// l2 = list([3,4,5]); // Returns: [3,4,5] // l2 = list([3,4,5]); // Returns: [3,4,5]

View File

@ -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) = function bezier_segment_length(curve, start_u=0, end_u=1, max_deflect=0.01) =
let( let(
segs = len(curve) * 2, segs = len(curve) * 2,
uvals = lerpn(start_u, end_u, segs), uvals = lerpn(start_u, end_u, segs+1),
path = bezier_points(curve,uvals), path = bezier_points(curve,uvals),
defl = max([ defl = max([
for (i=idx(path,e=-3)) let( 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]) for (seg = [0:1:segs-1])
each bezier_points(select(bezier, seg*N, (seg+1)*N), [0:step:1-step/2]), 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)
]; ];

View File

@ -494,7 +494,7 @@ function rand_int(minval, maxval, N, seed=undef) =
function gaussian_rands(mean, stddev, N=1, 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.") 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)) 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() // Function: log_rands()

View File

@ -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)], bpatch = [for(i=[0:1:len(patch[0])-1]) bezier_points(subindex(patch,i), samplepts)],
pts = [ pts = [
[bpatch[0][0]], [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) vnf = vnf_tri_array(pts, reverse=reverse)
) [ ) [

View File

@ -987,8 +987,8 @@ module test_pointlist_bounds() {
module test_closest_point() { module test_closest_point() {
ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463)]; 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)]; testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834+i)];
for (pt = testpts) { for (pt = testpts) {
pidx = closest_point(pt,ptlist); pidx = closest_point(pt,ptlist);
dists = [for (p=ptlist) norm(pt-p)]; dists = [for (p=ptlist) norm(pt-p)];
@ -1000,8 +1000,8 @@ module test_closest_point() {
module test_furthest_point() { module test_furthest_point() {
ptlist = [for (i=count(100)) rands(-100,100,2,seed_value=8463)]; 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)]; testpts = [for (i=count(100)) rands(-100,100,2,seed_value=6834+i)];
for (pt = testpts) { for (pt = testpts) {
pidx = furthest_point(pt,ptlist); pidx = furthest_point(pt,ptlist);
dists = [for (p=ptlist) norm(pt-p)]; dists = [for (p=ptlist) norm(pt-p)];