fix doc errors

This commit is contained in:
Adrian Mariano
2021-11-06 19:29:49 -04:00
parent 4315b8c0b6
commit b6937b539e
2 changed files with 58 additions and 5 deletions

View File

@@ -104,3 +104,54 @@ module test_exclusive_or() {
}
test_exclusive_or();
module test_point_in_region(){
region = [for(i=[2:8]) hexagon(r=i)];
pir=[for(x=[-6:6],y=[-6:6]) point_in_region([x,y],region)];
assert_equal(pir,
[-1, -1, -1, 1, 1, -1, 0, -1, 1, 1, -1, -1, -1, -1, 1, 1,
-1, -1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 0,
-1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 0, 1, -1, -1, 1,
1, -1, -1, 1, -1, 1, 1, -1, 0, -1, 1, 1, -1, 1, -1, -1, 1,
-1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1,
1, 1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1,
-1, 1, -1, -1, 1, -1, 1, 1, -1, 0, -1, 1, 1, -1, 1, -1, -1,
1, 1, -1, -1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1,
-1, 0, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 0, 1, -1,
-1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 0, -1, 1, 1, -1, -1, -1]);
}
test_point_in_region();
module test_make_region(){
pentagram = turtle(["move",100,"left",144], repeat=4);
region1 = make_region(pentagram);
assert_approx(region1,
[[[0, 0], [38.196601125, 0], [30.9016994375, 22.451398829]], [[50,
36.3271264003], [19.0983005625, 58.7785252292], [30.9016994375,
22.451398829]], [[69.0983005625, 22.451398829], [50, 36.3271264003],
[80.9016994375, 58.7785252292]], [[61.803398875, 3.5527136788e-15],
[69.0983005625, 22.451398829], [100, 0]], [[38.196601125, 0],
[61.803398875, 3.94430452611e-31], [50, -36.3271264003]]]);
region2 = make_region(pentagram,nonzero=true);
assert_approx(region2,
[[[0, 0], [38.196601125, 0], [50, -36.3271264003],
[61.803398875, 3.5527136788e-15], [100, 0],
[69.0983005625, 22.451398829], [80.9016994375,
58.7785252292], [50, 36.3271264003], [19.0983005625,
58.7785252292], [30.9016994375, 22.451398829]]]);
region3 = make_region([square(10), move([5,5],square(8))]);
assert_equal(region3, [[[10, 0], [0, 0], [0, 10], [5, 10], [5, 5], [10, 5]], [[5, 10], [10, 10], [10, 5], [13, 5], [13, 13], [5, 13]]]);
}
test_make_region();
module test_region_area(){
assert_equal(region_area([square(10), right(20,square(8))]), 164);
}
test_region_area();