mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
Fix caucluation of rotation between two vectors during auto-orient (#4144)
* Properly extract rotation matrix * Another attempt to fix auto-orient
This commit is contained in:
parent
a74a1d26fd
commit
bff50a5fd8
2 changed files with 4 additions and 5 deletions
|
@ -418,7 +418,7 @@ Vec3d extract_euler_angles(const Transform3d& transform)
|
||||||
|
|
||||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, double& phi, Matrix3d* rotation_matrix)
|
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, double& phi, Matrix3d* rotation_matrix)
|
||||||
{
|
{
|
||||||
const Matrix3d m = Transform3d(Eigen::Quaterniond().setFromTwoVectors(from, to)).matrix().block<3, 3>(0, 0);
|
const Matrix3d m = Eigen::Quaterniond().setFromTwoVectors(from, to).toRotationMatrix();
|
||||||
const Eigen::AngleAxisd aa(m);
|
const Eigen::AngleAxisd aa(m);
|
||||||
rotation_axis = aa.axis();
|
rotation_axis = aa.axis();
|
||||||
phi = aa.angle();
|
phi = aa.angle();
|
||||||
|
|
|
@ -1298,10 +1298,9 @@ public:
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
void rotate(Matrix3d rotation_matrix) {
|
void rotate(Matrix3d rotation_matrix) {
|
||||||
auto R = m_transformation.get_rotation_matrix().matrix().block<3, 3>(0, 0);
|
auto rotation = m_transformation.get_rotation_matrix();
|
||||||
auto R_new = rotation_matrix * R;
|
rotation = rotation_matrix * rotation;
|
||||||
auto euler_angles = Geometry::extract_euler_angles(R_new);
|
set_rotation(Geometry::Transformation(rotation).get_rotation());
|
||||||
set_rotation(euler_angles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d get_scaling_factor() const { return m_transformation.get_scaling_factor(); }
|
Vec3d get_scaling_factor() const { return m_transformation.get_scaling_factor(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue