Various arrays.scad docs updates. Bugfixes.

This commit is contained in:
Garth Minette
2021-01-24 23:26:39 -08:00
parent 330647dd18
commit 320518194f
13 changed files with 205 additions and 175 deletions

View File

@@ -266,9 +266,9 @@ test_list_fit();
module test_idx() {
colors = ["red", "green", "blue", "cyan"];
assert([for (i=idx(colors)) i] == [0,1,2,3]);
assert([for (i=idx(colors,end=-2)) i] == [0,1,2]);
assert([for (i=idx(colors,start=1)) i] == [1,2,3]);
assert([for (i=idx(colors,start=1,end=-2)) i] == [1,2]);
assert([for (i=idx(colors,e=-2)) i] == [0,1,2]);
assert([for (i=idx(colors,s=1)) i] == [1,2,3]);
assert([for (i=idx(colors,s=1,e=-2)) i] == [1,2]);
}
test_idx();
@@ -449,31 +449,25 @@ test_force_list();
module test_pair() {
assert(pair([3,4,5,6]) == [[3,4], [4,5], [5,6]]);
assert(pair("ABCD") == [["A","B"], ["B","C"], ["C","D"]]);
assert(pair([3,4,5,6],true) == [[3,4], [4,5], [5,6], [6,3]]);
assert(pair("ABCD",true) == [["A","B"], ["B","C"], ["C","D"], ["D","A"]]);
assert(pair([3,4,5,6],wrap=true) == [[3,4], [4,5], [5,6], [6,3]]);
assert(pair("ABCD",wrap=true) == [["A","B"], ["B","C"], ["C","D"], ["D","A"]]);
}
test_pair();
module test_pair_wrap() {
assert(pair_wrap([3,4,5,6]) == [[3,4], [4,5], [5,6], [6,3]]);
assert(pair_wrap("ABCD") == [["A","B"], ["B","C"], ["C","D"], ["D","A"]]);
}
test_pair_wrap();
module test_triplet() {
assert(triplet([3,4,5,6,7]) == [[3,4,5], [4,5,6], [5,6,7]]);
assert(triplet("ABCDE") == [["A","B","C"], ["B","C","D"], ["C","D","E"]]);
assert(triplet([3,4,5,6],true) == [[3,4,5], [4,5,6], [5,6,3], [6,3,4]]);
assert(triplet("ABCD",true) == [["A","B","C"], ["B","C","D"], ["C","D","A"], ["D","A","B"]]);
assert(triplet([3,4,5,6],wrap=true) == [[3,4,5], [4,5,6], [5,6,3], [6,3,4]]);
assert(triplet("ABCD",wrap=true) == [["A","B","C"], ["B","C","D"], ["C","D","A"], ["D","A","B"]]);
}
test_triplet();
module test_triplet_wrap() {
assert(triplet_wrap([3,4,5,6]) == [[3,4,5], [4,5,6], [5,6,3], [6,3,4]]);
assert(triplet_wrap("ABCD") == [["A","B","C"], ["B","C","D"], ["C","D","A"], ["D","A","B"]]);
}
test_triplet_wrap();
module test_permute() {
assert(permute([3,4,5,6]) == [[3,4],[3,5],[3,6],[4,5],[4,6],[5,6]]);
assert(permute([3,4,5,6],n=3) == [[3,4,5],[3,4,6],[3,5,6],[4,5,6]]);

View File

@@ -394,7 +394,7 @@ module test_line_normal() {
assert(line_normal([[0,0],[0,-10]]) == [1,0]);
assert(approx(line_normal([[0,0],[10,10]]), [-sqrt(2)/2,sqrt(2)/2]));
pts = [for (p=pair(rands(-100,100,1000,seed_value=4312))) p];
for (p = pair_wrap(pts)) {
for (p = pair(pts,true)) {
p1 = p.x;
p2 = p.y;
n = unit(p2-p1);
@@ -619,7 +619,7 @@ module test_circle_point_tangents() {
module test_tri_calc() {
sides = rands(1,100,100,seed_value=8888);
for (p=pair_wrap(sides)) {
for (p=pair(sides,true)) {
opp = p[0];
adj = p[1];
hyp = norm([opp,adj]);
@@ -642,7 +642,7 @@ module test_tri_calc() {
module test_tri_functions() {
sides = rands(1,100,100,seed_value=8181);
for (p = pair_wrap(sides)) {
for (p = pair(sides,true)) {
adj = p.x;
opp = p.y;
hyp = norm([opp,adj]);