Added reverse_polygon() and improved ccw_polygon() and clockwise_polygon()

This commit is contained in:
Revar Desmera
2019-11-17 18:19:55 -08:00
parent 2b95e67cda
commit bb92d788ef
3 changed files with 26 additions and 6 deletions

View File

@@ -655,20 +655,31 @@ test_polygon_is_clockwise();
module test_clockwise_polygon() {
path = circle(d=100);
rpath = concat([path[0]], reverse(select(path,1,-1)));
assert(clockwise_polygon(path) == path);
assert(clockwise_polygon(reverse(path)) == path);
assert(clockwise_polygon(rpath) == path);
}
test_clockwise_polygon();
module test_ccw_polygon() {
path = circle(d=100);
assert(ccw_polygon(path) == reverse(path));
assert(ccw_polygon(reverse(path)) == reverse(path));
rpath = concat([path[0]], reverse(select(path,1,-1)));
assert(ccw_polygon(path) == rpath);
assert(ccw_polygon(rpath) == rpath);
}
test_ccw_polygon();
module test_reverse_polygon() {
path = circle(d=100);
rpath = concat([path[0]], reverse(select(path,1,-1)));
assert(reverse_polygon(path) == rpath);
assert(reverse_polygon(rpath) == path);
}
test_reverse_polygon();
module test_is_region() {
assert(is_region([circle(d=10),square(10)]));
assert(is_region([circle(d=10),square(10),circle(d=50)]));