PrusaSlicer-NonPlainar/lib/Slic3r/Line.pm
Alessandro Ranellucci b38cc2c244 Merge branch 'master' into xsdata
Conflicts:
	lib/Slic3r.pm
	lib/Slic3r/ExPolygon.pm
	lib/Slic3r/Fill.pm
	lib/Slic3r/Fill/Rectilinear.pm
	lib/Slic3r/GCode.pm
	lib/Slic3r/GUI/Plater.pm
	lib/Slic3r/Geometry/Clipper.pm
	lib/Slic3r/Layer/Region.pm
	lib/Slic3r/Print.pm
	lib/Slic3r/Print/Object.pm
	lib/Slic3r/TriangleMesh.pm
	t/shells.t
	xs/MANIFEST
2013-08-08 02:10:34 +02:00

59 lines
1.2 KiB
Perl

package Slic3r::Line;
use strict;
use warnings;
# a line is a two-points line
use parent 'Slic3r::Polyline';
use Slic3r::Geometry qw(A B X Y);
sub coincides_with {
my $self = shift;
my ($line) = @_;
return ($self->a->coincides_with($line->a) && $self->b->coincides_with($line->b))
|| ($self->a->coincides_with($line->b) && $self->b->coincides_with($line->a));
}
sub vector {
my $self = shift;
return (ref $self)->new([0,0], [map $self->[B][$_] - $self->[A][$_], X,Y]);
}
sub atan {
my $self = shift;
return Slic3r::Geometry::line_atan($self);
}
sub direction {
my $self = shift;
return Slic3r::Geometry::line_direction($self);
}
sub intersection {
my $self = shift;
my ($line, $require_crossing) = @_;
return Slic3r::Geometry::line_intersection($self, $line, $require_crossing);
}
sub point_on_left {
my $self = shift;
my ($point) = @_;
return Slic3r::Geometry::point_is_on_left_of_segment($point, $self);
}
sub midpoint {
my $self = shift;
return Slic3r::Point->new(
($self->[A][X] + $self->[B][X]) / 2,
($self->[A][Y] + $self->[B][Y]) / 2,
);
}
sub grow {
my $self = shift;
return Slic3r::Polyline->new(@$self[0,1,0])->grow(@_);
}
1;