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
This commit is contained in:
Arthur 2023-09-07 14:44:43 +08:00 committed by Lane.Wei
parent 4c68a7634c
commit 3c691ac086

View File

@ -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); }