New Point::projection_onto() methods

This commit is contained in:
Alessandro Ranellucci 2014-05-21 20:08:21 +02:00
parent 874c7a6e8b
commit 254ab29a97
4 changed files with 83 additions and 1 deletions

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 10;
use Test::More tests => 13;
my $point = Slic3r::Point->new(10, 15);
is_deeply [ @$point ], [10, 15], 'point roundtrip';
@ -46,4 +46,16 @@ ok !$point->coincides_with($point2), 'coincides_with';
ok $p0->ccw($p1, $p2) < 0, 'ccw() does not overflow';
}
{
my $point = Slic3r::Point->new(15,15);
my $line = Slic3r::Line->new([10,10], [20,10]);
is_deeply $point->projection_onto_line($line)->pp, [15,10], 'project_onto_line';
$point = Slic3r::Point->new(0, 15);
is_deeply $point->projection_onto_line($line)->pp, [10,10], 'project_onto_line';
$point = Slic3r::Point->new(25, 15);
is_deeply $point->projection_onto_line($line)->pp, [20,10], 'project_onto_line';
}
__END__