Refactoring, new bounding_box_3D function
This commit is contained in:
parent
35e449e891
commit
b5672de3ca
@ -20,7 +20,7 @@ our @EXPORT_OK = qw(
|
||||
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 polygon_is_convex
|
||||
scaled_epsilon
|
||||
scaled_epsilon bounding_box_3D
|
||||
);
|
||||
|
||||
|
||||
@ -707,6 +707,20 @@ sub bounding_box_intersect {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# 3D
|
||||
sub bounding_box_3D {
|
||||
my ($points) = @_;
|
||||
|
||||
my @extents = (map [undef, undef], X,Y,Z);
|
||||
foreach my $point (@$points) {
|
||||
for (X,Y,Z) {
|
||||
$extents[$_][MIN] = $point->[$_] if !defined $extents[$_][MIN] || $point->[$_] < $extents[$_][MIN];
|
||||
$extents[$_][MAX] = $point->[$_] if !defined $extents[$_][MAX] || $point->[$_] > $extents[$_][MAX];
|
||||
}
|
||||
}
|
||||
return @extents;
|
||||
}
|
||||
|
||||
sub angle3points {
|
||||
my ($p1, $p2, $p3) = @_;
|
||||
# p1 is the center
|
||||
|
@ -381,14 +381,7 @@ sub duplicate {
|
||||
|
||||
sub extents {
|
||||
my $self = shift;
|
||||
my @extents = (map [undef, undef], X,Y,Z);
|
||||
foreach my $vertex (@{$self->vertices}) {
|
||||
for (X,Y,Z) {
|
||||
$extents[$_][MIN] = $vertex->[$_] if !defined $extents[$_][MIN] || $vertex->[$_] < $extents[$_][MIN];
|
||||
$extents[$_][MAX] = $vertex->[$_] if !defined $extents[$_][MAX] || $vertex->[$_] > $extents[$_][MAX];
|
||||
}
|
||||
}
|
||||
return @extents;
|
||||
return Slic3r::Geometry::bounding_box_3D($self->vertices);
|
||||
}
|
||||
|
||||
sub size {
|
||||
|
Loading…
Reference in New Issue
Block a user