Optimization of travel paths for perimeters

This commit is contained in:
Alessandro Ranellucci 2011-09-25 23:15:45 +02:00
parent 03341f3485
commit 0cd10441a1
7 changed files with 113 additions and 46 deletions

View file

@ -18,11 +18,11 @@ sub id {
}
sub cast {
my $self = shift;
my $class = shift;
my ($points) = @_;
@$points = map { ref $_ eq 'ARRAY' ? Slic3r::Point->cast($_) : $_ } @$points;
return __PACKAGE__->new(points => $points);
return $class->new(points => $points);
}
sub lines {
@ -82,4 +82,15 @@ sub make_clockwise {
$self->reverse_points if $self->is_counter_clockwise;
}
sub nearest_point_to {
my $self = shift;
my ($point) = @_;
# get point as arrayref
$point = ref $point eq 'ARRAY' ? $point : $point->p;
$point = Slic3r::Geometry::nearest_point($point, $self->p);
return Slic3r::Point->cast($point);
}
1;