diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2012-02-25 19:14:59 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2012-02-25 19:14:59 +0400 |
commit | a24ffee2aa9cc1fc87f5a6a146b09afbd385af07 (patch) | |
tree | f7e6feb7ec5156b1c7a74c537bee1102a37c50ce /t/geometry.t | |
parent | 2d130061edaa011d4f5d0a69923e7f1ab03a6507 (diff) |
New polygon_is_convex() function
Diffstat (limited to 't/geometry.t')
-rw-r--r-- | t/geometry.t | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/t/geometry.t b/t/geometry.t index bc81cb610..0ff61e375 100644 --- a/t/geometry.t +++ b/t/geometry.t @@ -2,7 +2,7 @@ use Test::More; use strict; use warnings; -plan tests => 17; +plan tests => 20; BEGIN { use FindBin; @@ -12,7 +12,7 @@ BEGIN { use Slic3r; use Slic3r::Geometry qw(PI polyline_remove_parallel_continuous_edges polyline_remove_acute_vertices polygon_remove_acute_vertices - polygon_remove_parallel_continuous_edges); + polygon_remove_parallel_continuous_edges polygon_is_convex); #========================================================== @@ -143,4 +143,15 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po is scalar(@$polygon), 6, 'polyline_remove_acute_vertices'; } +#========================================================== + +{ + my $cw_square = [ [0,0], [0,10], [10,10], [10,0] ]; + is polygon_is_convex($cw_square), 0, 'cw square is not convex'; + is polygon_is_convex([ reverse @$cw_square ]), 1, 'ccw square is convex'; + + my $convex1 = [ [0,0], [10,0], [10,10], [0,10], [0,6], [4,6], [4,4], [0,4] ]; + is polygon_is_convex($convex1), 0, 'concave polygon'; +} + #==========================================================
\ No newline at end of file |