From 3c691ac086da3db2de27e9aa8163ddf1b22996c3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 7 Sep 2023 14:44:43 +0800 Subject: [PATCH] ENH: improve auto-arranging's aligning to Y axis Dominant direction is more accurate (solve the problem that cubes are not arranged neatly). Jira: STUDIO-4356 Change-Id: I8931f51a97bee96d5d9e75306481eae2e0cdc059 --- src/libslic3r/Arrange.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 8d1b3d12a0..6eb262e652 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -217,8 +217,14 @@ void update_selected_items_axis_align(ArrangePolygons& selected, const DynamicPr double b = m11 / m00 - cx * cy; double c = m02 / m00 - cy * cy; - angle = std::atan2(2 * b, (a - c)) / 2; - validResult = true; + //if a and c are close, there is no dominant axis, then do not rotate + if (std::abs(a) < 1.5*std::abs(c) && std::abs(c) < 1.5*std::abs(a)) { + validResult = false; + } + else { + angle = std::atan2(2 * b, (a - c)) / 2; + validResult = true; + } } } if (validResult) { ap.rotation += (PI / 2 - angle); }