From d056535bd8c23f0b82a2b7ebb9d9b3fa91989876 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 4 Dec 2011 17:09:06 +0100 Subject: [PATCH] Further corrections to the bridge angle detection algorithm. #58 --- lib/Slic3r/Layer.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 9f55487b8..10e0a2ce4 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -285,7 +285,15 @@ sub process_bridges { ); } - if (@edges) { + if (@edges == 2) { + my @chords = map Slic3r::Line->new($_->points->[0], $_->points->[-1]), @edges; + my @midpoints = map $_->midpoint, @chords; + my $line_between_midpoints = Slic3r::Line->new(@midpoints); + $bridge_angle = rad2deg_dir($line_between_midpoints->direction); + } elsif (@edges == 1) { + my $line = Slic3r::Line->new($edges[0]->points->[0], $edges[0]->points->[-1]); + $bridge_angle = rad2deg_dir($line->direction); + } else { my $center = bounding_box_center([ map @{$_->points}, @edges ]); my $x = my $y = 0; foreach my $point (map @{$_->points}, @edges) {