mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-05 18:10:39 +08:00
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:
parent
4c68a7634c
commit
3c691ac086
@ -217,8 +217,14 @@ void update_selected_items_axis_align(ArrangePolygons& selected, const DynamicPr
|
|||||||
double b = m11 / m00 - cx * cy;
|
double b = m11 / m00 - cx * cy;
|
||||||
double c = m02 / m00 - cy * cy;
|
double c = m02 / m00 - cy * cy;
|
||||||
|
|
||||||
angle = std::atan2(2 * b, (a - c)) / 2;
|
//if a and c are close, there is no dominant axis, then do not rotate
|
||||||
validResult = true;
|
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); }
|
if (validResult) { ap.rotation += (PI / 2 - angle); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user