mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-30 19:40:07 +02:00
Fixed bugs in hull_points, added seeds to tests, added seed parm to shuffle()
This commit is contained in:
@@ -268,13 +268,16 @@ test_enumerate();
|
||||
|
||||
module test_shuffle() {
|
||||
nums1 = [for (i=list_range(100)) i];
|
||||
nums2 = shuffle(nums1);
|
||||
nums3 = shuffle(nums2);
|
||||
assert(len(nums2)==len(nums1));
|
||||
assert(len(nums3)==len(nums2));
|
||||
nums2 = shuffle(nums1,33);
|
||||
nums3 = shuffle(nums2,99);
|
||||
assert(sort(nums2)==nums1);
|
||||
assert(sort(nums3)==nums1);
|
||||
assert(nums1!=nums2);
|
||||
assert(nums2!=nums3);
|
||||
assert(nums1!=nums3);
|
||||
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
shufstr = shuffle(str,12);
|
||||
assert(shufstr != str && sort(shufstr)==str);
|
||||
}
|
||||
test_shuffle();
|
||||
|
||||
|
@@ -112,8 +112,8 @@ function info_str(list,i=0,string=chr(10)) =
|
||||
|
||||
|
||||
module test_closest_point_on_plane(){
|
||||
plane = rands(-5,5,4)+[10,0,0,0];
|
||||
point = rands(-1,1,3);
|
||||
plane = rands(-5,5,4,seed=175)+[10,0,0,0];
|
||||
point = rands(-1,1,3,seed=477);
|
||||
point2 = closest_point_on_plane(plane,point);
|
||||
assert_approx(norm(point-point2), abs(distance_from_plane(plane,point)));
|
||||
}
|
||||
@@ -121,7 +121,7 @@ module test_closest_point_on_plane(){
|
||||
|
||||
|
||||
module test_normalize_plane(){
|
||||
plane = rands(-5,5,4)+[10,0,0,0];
|
||||
plane = rands(-5,5,4,seed=333)+[10,0,0,0];
|
||||
plane2 = normalize_plane(plane);
|
||||
assert_approx(norm(point3d(plane2)),1);
|
||||
assert_approx(plane*plane2[3],plane2*plane[3]);
|
||||
@@ -129,7 +129,7 @@ module test_normalize_plane(){
|
||||
*test_normalize_plane();
|
||||
|
||||
module test_plane_line_intersection(){
|
||||
line = [rands(-1,1,3),rands(-1,1,3)+[2,0,0]];
|
||||
line = [rands(-1,1,3,seed=74),rands(-1,1,3,seed=99)+[2,0,0]];
|
||||
plane1 = plane_from_normal(line[1]-line[0],2*line[0]-line[1]); // plane disjoint from segment
|
||||
plane2 = plane_from_normal(line[1]-line[0],(line[0]+line[1])/2); // through middle point of line
|
||||
plane3 = plane3pt(line[1],line[0], rands(-1,1,3)+[0,3,0]); // containing line
|
||||
|
@@ -238,7 +238,7 @@ test_approx();
|
||||
|
||||
|
||||
module test_min_index() {
|
||||
vals = rands(-100,100,100);
|
||||
vals = rands(-100,100,100,seed=75);
|
||||
minval = min(vals);
|
||||
minidx = min_index(vals);
|
||||
assert_equal(vals[minidx], minval);
|
||||
@@ -254,7 +254,7 @@ test_min_index();
|
||||
|
||||
|
||||
module test_max_index() {
|
||||
vals = rands(-100,100,100);
|
||||
vals = rands(-100,100,100,seed=97);
|
||||
maxval = max(vals);
|
||||
maxidx = max_index(vals);
|
||||
assert_equal(vals[maxidx], maxval);
|
||||
|
Reference in New Issue
Block a user