|
@@ -4,7 +4,10 @@ use strict;
|
|
|
use warnings;
|
|
|
|
|
|
use Slic3r::XS;
|
|
|
-use Test::More tests => 6;
|
|
|
+use Test::More tests => 34;
|
|
|
+
|
|
|
+use constant PI => 4 * atan2(1, 1);
|
|
|
+use constant EPSILON => 1E-4;
|
|
|
|
|
|
my $points = [
|
|
|
[100, 100],
|
|
@@ -37,4 +40,28 @@ isa_ok $line->[0], 'Slic3r::Point::Ref', 'line point is blessed';
|
|
|
], 'translate';
|
|
|
}
|
|
|
|
|
|
+foreach my $base_angle (0, PI/4, PI/2, PI) {
|
|
|
+ my $line = Slic3r::Line->new([0,0], [100,0]);
|
|
|
+ $line->rotate($base_angle, [0,0]);
|
|
|
+ ok $line->parallel_to_line($line->clone), 'line is parallel to self';
|
|
|
+ ok $line->parallel_to($line->direction), 'line is parallel to its direction';
|
|
|
+ ok $line->parallel_to($line->direction + PI), 'line is parallel to its direction + PI';
|
|
|
+ ok $line->parallel_to($line->direction - PI), 'line is parallel to its direction - PI';
|
|
|
+ {
|
|
|
+ my $line2 = $line->clone;
|
|
|
+ $line2->reverse;
|
|
|
+ ok $line->parallel_to_line($line2), 'line is parallel to its opposite';
|
|
|
+ }
|
|
|
+ {
|
|
|
+ my $line2 = $line->clone;
|
|
|
+ $line2->rotate(+EPSILON/2, [0,0]);
|
|
|
+ ok $line->parallel_to_line($line2), 'line is parallel within epsilon';
|
|
|
+ }
|
|
|
+ {
|
|
|
+ my $line2 = $line->clone;
|
|
|
+ $line2->rotate(-EPSILON/2, [0,0]);
|
|
|
+ ok $line->parallel_to_line($line2), 'line is parallel within epsilon';
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
__END__
|