Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix caucluation of rotation between two vectors during auto-orient #4144

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libslic3r/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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);
rotation_axis = aa.axis();
phi = aa.angle();
Expand Down
7 changes: 3 additions & 4 deletions src/libslic3r/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,10 +1298,9 @@ class ModelInstance final : public ObjectBase

// BBS
void rotate(Matrix3d rotation_matrix) {
auto R = m_transformation.get_rotation_matrix().matrix().block<3, 3>(0, 0);
auto R_new = rotation_matrix * R;
auto euler_angles = Geometry::extract_euler_angles(R_new);
set_rotation(euler_angles);
auto rotation = m_transformation.get_rotation_matrix();
rotation = rotation_matrix * rotation;
set_rotation(Geometry::Transformation(rotation).get_rotation());
}

Vec3d get_scaling_factor() const { return m_transformation.get_scaling_factor(); }
Expand Down
Loading