mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-27 19:10:16 +02:00
fix tests
This commit is contained in:
@@ -7,7 +7,6 @@ include <../std.scad>
|
||||
|
||||
|
||||
test_point_on_segment();
|
||||
test_point_left_of_line2d();
|
||||
test_collinear();
|
||||
test_point_line_distance();
|
||||
test_segment_distance();
|
||||
@@ -31,7 +30,6 @@ test_point_plane_distance();
|
||||
|
||||
test__general_plane_line_intersection();
|
||||
test_plane_line_angle();
|
||||
test_normalize_plane();
|
||||
test_plane_line_intersection();
|
||||
test_polygon_line_intersection();
|
||||
test_plane_intersection();
|
||||
@@ -90,13 +88,13 @@ function info_str(list,i=0,string=chr(10)) =
|
||||
: info_str(list,i+1,str(string,str(list[i][0],_valstr(list[i][1]),chr(10))));
|
||||
|
||||
|
||||
module test_normalize_plane(){
|
||||
module test__normalize_plane(){
|
||||
plane = rands(-5,5,4,seed=333)+[10,0,0,0];
|
||||
plane2 = normalize_plane(plane);
|
||||
plane2 = _normalize_plane(plane);
|
||||
assert_approx(norm(point3d(plane2)),1);
|
||||
assert_approx(plane*plane2[3],plane2*plane[3]);
|
||||
}
|
||||
*test_normalize_plane();
|
||||
test__normalize_plane();
|
||||
|
||||
module test_plane_line_intersection(){
|
||||
line = [rands(-1,1,3,seed=74),rands(-1,1,3,seed=99)+[2,0,0]];
|
||||
@@ -148,7 +146,7 @@ module test_plane_intersection(){
|
||||
module test_plane_offset(){
|
||||
plane = rands(-1,1,4)+[2,0,0,0]; // a valid plane
|
||||
info = info_str([["plane = ",plane]]);
|
||||
assert_approx(plane_offset(plane), normalize_plane(plane)[3],info);
|
||||
assert_approx(plane_offset(plane), _normalize_plane(plane)[3],info);
|
||||
assert_approx(plane_offset([1,1,1,1]), 1/sqrt(3),info);
|
||||
}
|
||||
*test_plane_offset();
|
||||
@@ -301,12 +299,12 @@ module test_point_on_segment() {
|
||||
*test_point_on_segment();
|
||||
|
||||
|
||||
module test_point_left_of_line2d() {
|
||||
assert(point_left_of_line2d([ -3, 0], [[-10,-10], [10,10]]) > 0);
|
||||
assert(point_left_of_line2d([ 0, 0], [[-10,-10], [10,10]]) == 0);
|
||||
assert(point_left_of_line2d([ 3, 0], [[-10,-10], [10,10]]) < 0);
|
||||
module test__point_left_of_line2d() {
|
||||
assert(_point_left_of_line2d([ -3, 0], [[-10,-10], [10,10]]) > 0);
|
||||
assert(_point_left_of_line2d([ 0, 0], [[-10,-10], [10,10]]) == 0);
|
||||
assert(_point_left_of_line2d([ 3, 0], [[-10,-10], [10,10]]) < 0);
|
||||
}
|
||||
*test_point_left_of_line2d();
|
||||
test__point_left_of_line2d();
|
||||
|
||||
module test_collinear() {
|
||||
assert(collinear([-10,-10], [-15, -16], [10,10]) == false);
|
||||
|
@@ -17,8 +17,8 @@ module test_circle() {
|
||||
for (pt = circle(r=100)) {
|
||||
assert(approx(norm(pt),100));
|
||||
}
|
||||
assert(polygon_is_clockwise(circle(d=200)));
|
||||
assert(polygon_is_clockwise(circle(r=100)));
|
||||
assert(is_polygon_clockwise(circle(d=200)));
|
||||
assert(is_polygon_clockwise(circle(r=100)));
|
||||
assert(len(circle(d=100,$fn=6)) == 6);
|
||||
assert(len(circle(d=100,$fn=36)) == 36);
|
||||
}
|
||||
|
@@ -217,32 +217,6 @@ module test_zflip() {
|
||||
test_zflip();
|
||||
|
||||
|
||||
module test_xyflip() {
|
||||
assert_approx(xyflip(), [[0,1,0,0],[1,0,0,0],[0,0,1,0],[0,0,0,1]]);
|
||||
assert_approx(xyflip(p=[1,2,3]), [2,1,3]);
|
||||
// Verify that module at least doesn't crash.
|
||||
xyflip() nil();
|
||||
}
|
||||
test_xyflip();
|
||||
|
||||
|
||||
module test_xzflip() {
|
||||
assert_approx(xzflip(), [[0,0,1,0],[0,1,0,0],[1,0,0,0],[0,0,0,1]]);
|
||||
assert_approx(xzflip(p=[1,2,3]), [3,2,1]);
|
||||
// Verify that module at least doesn't crash.
|
||||
xzflip() nil();
|
||||
}
|
||||
test_xzflip();
|
||||
|
||||
|
||||
module test_yzflip() {
|
||||
assert_approx(yzflip(), [[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]]);
|
||||
assert_approx(yzflip(p=[1,2,3]), [1,3,2]);
|
||||
// Verify that module at least doesn't crash.
|
||||
yzflip() nil();
|
||||
}
|
||||
test_yzflip();
|
||||
|
||||
|
||||
module test_rot() {
|
||||
pts2d = 50 * [for (x=[-1,0,1],y=[-1,0,1]) [x,y]];
|
||||
@@ -403,67 +377,10 @@ module test_zrot() {
|
||||
test_zrot();
|
||||
|
||||
|
||||
module test_xyrot() {
|
||||
vals = [-270,-135,-90,45,0,30,45,90,135,147,180];
|
||||
path = path3d(pentagon(d=100), 50);
|
||||
for (a=vals) {
|
||||
m = affine3d_rot_by_axis(RIGHT+BACK,a);
|
||||
assert_approx(xyrot(a), m);
|
||||
assert_approx(xyrot(a, p=path[0]), apply(m, path[0]));
|
||||
assert_approx(xyrot(a, p=path), apply(m, path));
|
||||
// Verify that module at least doesn't crash.
|
||||
xyrot(a) nil();
|
||||
}
|
||||
}
|
||||
test_xyrot();
|
||||
|
||||
|
||||
module test_xzrot() {
|
||||
vals = [-270,-135,-90,45,0,30,45,90,135,147,180];
|
||||
path = path3d(pentagon(d=100), 50);
|
||||
for (a=vals) {
|
||||
m = affine3d_rot_by_axis(RIGHT+UP,a);
|
||||
assert_approx(xzrot(a), m);
|
||||
assert_approx(xzrot(a, p=path[0]), apply(m, path[0]));
|
||||
assert_approx(xzrot(a, p=path), apply(m, path));
|
||||
// Verify that module at least doesn't crash.
|
||||
xzrot(a) nil();
|
||||
}
|
||||
}
|
||||
test_xzrot();
|
||||
|
||||
|
||||
module test_yzrot() {
|
||||
vals = [-270,-135,-90,45,0,30,45,90,135,147,180];
|
||||
path = path3d(pentagon(d=100), 50);
|
||||
for (a=vals) {
|
||||
m = affine3d_rot_by_axis(BACK+UP,a);
|
||||
assert_approx(yzrot(a), m);
|
||||
assert_approx(yzrot(a, p=path[0]), apply(m, path[0]));
|
||||
assert_approx(yzrot(a, p=path), apply(m, path));
|
||||
// Verify that module at least doesn't crash.
|
||||
yzrot(a) nil();
|
||||
}
|
||||
}
|
||||
test_yzrot();
|
||||
|
||||
|
||||
module test_xyzrot() {
|
||||
vals = [-270,-135,-90,45,0,30,45,90,135,147,180];
|
||||
path = path3d(pentagon(d=100), 50);
|
||||
for (a=vals) {
|
||||
m = affine3d_rot_by_axis(RIGHT+BACK+UP,a);
|
||||
assert_approx(xyzrot(a), m);
|
||||
assert_approx(xyzrot(a, p=path[0]), apply(m, path[0]));
|
||||
assert_approx(xyzrot(a, p=path), apply(m, path));
|
||||
// Verify that module at least doesn't crash.
|
||||
xyzrot(a) nil();
|
||||
}
|
||||
}
|
||||
test_xyzrot();
|
||||
|
||||
module test_frame_map() {
|
||||
assert(approx(frame_map(x=[1,1,0], y=[-1,1,0]), affine3d_zrot(45)));
|
||||
assert(approx(frame_map(x=[0,1,0], y=[0,0,1]), rot(v=[1,1,1],a=120)));
|
||||
}
|
||||
test_frame_map();
|
||||
|
||||
|
Reference in New Issue
Block a user