correct length calculation for clockwise arcs
This commit is contained in:
parent
28b851508e
commit
a81e8c4afc
@ -17,7 +17,11 @@ sub angle {
|
|||||||
sub length {
|
sub length {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
if($self->orientation eq 'ccw') {
|
||||||
return $self->radius * $self->angle;
|
return $self->radius * $self->angle;
|
||||||
|
} else {
|
||||||
|
return $self->radius * (2*PI() - $self->angle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
5
t/arcs.t
5
t/arcs.t
@ -2,7 +2,7 @@ use Test::More;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
plan tests => 10;
|
plan tests => 12;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use FindBin;
|
use FindBin;
|
||||||
@ -51,6 +51,9 @@ use Slic3r;
|
|||||||
isa_ok $collection1->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
|
isa_ok $collection1->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path';
|
||||||
isa_ok $collection2->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 $collection1->paths->[0]->orientation, 'cw', 'cw orientation was correctly detected';
|
||||||
is $collection2->paths->[0]->orientation, 'ccw', 'ccw orientation was correctly detected';
|
is $collection2->paths->[0]->orientation, 'ccw', 'ccw orientation was correctly detected';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user