Permalink
Browse files

Merge pull request #131 from sparr/master

this fixes a bug with arc lengths as discussed on IRC, including two unit tests
  • Loading branch information...
2 parents 55045e0 + a81e8c4 commit 1cc28844a50474ce339cf2a04bc00518d720a8b5 @alexrj alexrj committed Dec 22, 2011
Showing with 10 additions and 3 deletions.
  1. +5 −1 lib/Slic3r/ExtrusionPath/Arc.pm
  2. +5 −2 t/arcs.t
@@ -17,7 +17,11 @@ sub angle {
sub length {
my $self = shift;
- return $self->radius * $self->angle;
+ if($self->orientation eq 'ccw') {
+ return $self->radius * $self->angle;
+ } else {
+ return $self->radius * (2*PI() - $self->angle);
+ }
}
1;
View
@@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
-plan tests => 10;
+plan tests => 12;
BEGIN {
use FindBin;
@@ -50,7 +50,10 @@ use Slic3r;
isa_ok $collection1->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
isa_ok $collection2->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
-
+
+ is $collection1->paths->[0]->length, 7.06858347057701, 'cw oriented arc has correct length';
+ is $collection2->paths->[0]->length, 7.06858347057705, 'ccw oriented arc has correct length';
+
is $collection1->paths->[0]->orientation, 'cw', 'cw orientation was correctly detected';
is $collection2->paths->[0]->orientation, 'ccw', 'ccw orientation was correctly detected';

0 comments on commit 1cc2884

Please sign in to comment.