PrusaSlicer-NonPlainar/xs/t/14_geometry.t

35 lines
1.2 KiB
Perl
Raw Normal View History

2013-11-22 21:38:30 +00:00
#!/usr/bin/perl
use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 8;
use constant PI => 4 * atan2(1, 1);
2013-11-22 21:38:30 +00:00
{
my @points = (
Slic3r::Point->new(100,100),
Slic3r::Point->new(100,200),
Slic3r::Point->new(200,200),
Slic3r::Point->new(200,100),
Slic3r::Point->new(150,150),
);
my $hull = Slic3r::Geometry::convex_hull(\@points);
isa_ok $hull, 'Slic3r::Polygon', 'convex_hull returns a Polygon';
is scalar(@$hull), 4, 'convex_hull returns the correct number of points';
}
# directions_parallel() and directions_parallel_within() are tested
# also with Slic3r::Line::parallel_to() tests in 10_line.t
{
ok Slic3r::Geometry::directions_parallel_within(0, 0, 0), 'directions_parallel_within';
ok Slic3r::Geometry::directions_parallel_within(0, PI, 0), 'directions_parallel_within';
ok Slic3r::Geometry::directions_parallel_within(0, 0, PI/180), 'directions_parallel_within';
ok Slic3r::Geometry::directions_parallel_within(0, PI, PI/180), 'directions_parallel_within';
ok !Slic3r::Geometry::directions_parallel_within(PI/2, PI, 0), 'directions_parallel_within';
ok !Slic3r::Geometry::directions_parallel_within(PI/2, PI, PI/180), 'directions_parallel_within';
}
2013-11-22 21:38:30 +00:00
__END__