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

41 lines
1.4 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 => 9;
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';
}
{
2015-12-02 18:39:16 +00:00
my $positions = Slic3r::Geometry::arrange(4, Slic3r::Pointf->new(20, 20), 5);
is scalar(@$positions), 4, 'arrange() returns expected number of positions';
}
2013-11-22 21:38:30 +00:00
__END__