mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-09 07:01:46 +08:00
Removed function double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to) and remaining code using it
This commit is contained in:
parent
a784be24e7
commit
643d50813d
@ -872,24 +872,10 @@ Eigen::Quaterniond rotation_xyz_diff(const Vec3d &rot_xyz_from, const Vec3d &rot
|
||||
}
|
||||
|
||||
// This should only be called if it is known, that the two rotations only differ in rotation around the Z axis.
|
||||
double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)
|
||||
{
|
||||
const Eigen::AngleAxisd angle_axis(rotation_xyz_diff(rot_xyz_from, rot_xyz_to));
|
||||
const Vec3d& axis = angle_axis.axis();
|
||||
const double angle = angle_axis.angle();
|
||||
#ifndef NDEBUG
|
||||
if (std::abs(angle) > 1e-8) {
|
||||
assert(std::abs(axis.x()) < 1e-8);
|
||||
assert(std::abs(axis.y()) < 1e-8);
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
return (axis.z() < 0) ? -angle : angle;
|
||||
}
|
||||
|
||||
double rotation_diff_z(const Transform3d &trafo_from, const Transform3d &trafo_to)
|
||||
{
|
||||
auto m = trafo_to.linear() * trafo_from.linear().inverse();
|
||||
assert(std::abs(m.determinant() - 1));
|
||||
assert(std::abs(m.determinant() - 1) < EPSILON);
|
||||
Vec3d vx = m * Vec3d(1., 0., 0);
|
||||
// Verify that the linear part of rotation from trafo_from to trafo_to rotates around Z and is unity.
|
||||
assert(std::abs(std::hypot(vx.x(), vx.y()) - 1.) < 1e-5);
|
||||
|
@ -546,7 +546,6 @@ extern Transform3d transform3d_from_string(const std::string& transform_str);
|
||||
extern Eigen::Quaterniond rotation_xyz_diff(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to);
|
||||
// Rotation by Z to align rot_xyz_from to rot_xyz_to.
|
||||
// This should only be called if it is known, that the two rotations only differ in rotation around the Z axis.
|
||||
extern double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to);
|
||||
extern double rotation_diff_z(const Transform3d &trafo_from, const Transform3d &trafo_to);
|
||||
|
||||
// Is the angle close to a multiple of 90 degrees?
|
||||
|
@ -1780,7 +1780,7 @@ void ModelObject::bake_xy_rotation_into_meshes(size_t instance_idx)
|
||||
// Adjust the instances.
|
||||
for (size_t i = 0; i < this->instances.size(); ++ i) {
|
||||
ModelInstance &model_instance = *this->instances[i];
|
||||
model_instance.set_rotation(Vec3d(0., 0., Geometry::rotation_diff_z(reference_trafo.get_rotation(), model_instance.get_rotation())));
|
||||
model_instance.set_rotation(Vec3d(0., 0., Geometry::rotation_diff_z(reference_trafo.get_matrix(), model_instance.get_matrix())));
|
||||
model_instance.set_scaling_factor(Vec3d(new_scaling_factor, new_scaling_factor, new_scaling_factor));
|
||||
model_instance.set_mirror(Vec3d(1., 1., 1.));
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Transfor
|
||||
BoundingBoxf3 bbox = model_object->raw_bounding_box();
|
||||
Vec3d bbox_center = bbox.center();
|
||||
// We may need to rotate the bbox / bbox_center from the original instance to the current instance.
|
||||
double z_diff = Geometry::rotation_diff_z(model_object->instances.front()->get_rotation(), instances.front().model_instance->get_rotation());
|
||||
if (std::abs(z_diff) > EPSILON) {
|
||||
double z_diff = Geometry::rotation_diff_z(model_object->instances.front()->get_matrix(), instances.front().model_instance->get_matrix());
|
||||
if (std::abs(z_diff) > EPSILON) {
|
||||
auto z_rot = Eigen::AngleAxisd(z_diff, Vec3d::UnitZ());
|
||||
bbox = bbox.transformed(Transform3d(z_rot));
|
||||
bbox_center = (z_rot * bbox_center).eval();
|
||||
|
Loading…
x
Reference in New Issue
Block a user