mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
New polygon_is_convex() function
This commit is contained in:
@@ -5,7 +5,7 @@ use warnings;
|
||||
# an ExPolygon is a polygon with holes
|
||||
|
||||
use Math::Geometry::Voronoi;
|
||||
use Slic3r::Geometry qw(point_in_polygon X Y A B);
|
||||
use Slic3r::Geometry qw(X Y A B point_in_polygon);
|
||||
use Slic3r::Geometry::Clipper qw(union_ex JT_MITER);
|
||||
|
||||
# the constructor accepts an array of polygons
|
||||
|
||||
@@ -19,7 +19,7 @@ our @EXPORT_OK = qw(
|
||||
polygon_remove_acute_vertices polygon_remove_parallel_continuous_edges
|
||||
shortest_path collinear scale unscale merge_collinear_lines
|
||||
rad2deg_dir bounding_box_center line_intersects_any douglas_peucker
|
||||
polyline_remove_short_segments normal triangle_normal
|
||||
polyline_remove_short_segments normal triangle_normal polygon_is_convex
|
||||
);
|
||||
|
||||
use XXX;
|
||||
@@ -295,6 +295,15 @@ sub polygon_has_vertex {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub polygon_is_convex {
|
||||
my ($points) = @_;
|
||||
for (my $i = 0; $i <= $#$points; $i++) {
|
||||
my $angle = angle3points($points->[$i-1], $points->[$i-2], $points->[$i]);
|
||||
return 0 if $angle < PI;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub polyline_length {
|
||||
my ($polyline) = @_;
|
||||
my $length = 0;
|
||||
|
||||
Reference in New Issue
Block a user