mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-10-04 01:26:29 +08:00
add function to center around bb
This commit is contained in:
parent
f8c6c630ff
commit
d7c1f8bad8
@ -724,6 +724,13 @@ ModelObject::center_around_origin()
|
||||
}
|
||||
}
|
||||
|
||||
TransformationMatrix
|
||||
ModelObject::get_trafo_to_center() const
|
||||
{
|
||||
BoundingBoxf3 raw_bb = this->raw_bounding_box();
|
||||
return TransformationMatrix::mat_translation(raw_bb.center().negative());
|
||||
}
|
||||
|
||||
void
|
||||
ModelObject::translate(const Vectorf3 &vector)
|
||||
{
|
||||
@ -782,6 +789,17 @@ ModelObject::rotate(double angle, const Axis &axis)
|
||||
this->invalidate_bounding_box();
|
||||
}
|
||||
|
||||
void
|
||||
ModelObject::rotate(double angle, const Vectorf3 &axis)
|
||||
{
|
||||
if (angle == 0) return;
|
||||
TransformationMatrix trafo = TransformationMatrix::mat_rotation(angle, axis);
|
||||
this->apply_transformation(trafo);
|
||||
|
||||
this->origin_translation = Pointf3(0,0,0);
|
||||
this->invalidate_bounding_box();
|
||||
}
|
||||
|
||||
void
|
||||
ModelObject::rotate(const Vectorf3 &origin, const Vectorf3 &target)
|
||||
{
|
||||
|
@ -358,6 +358,9 @@ class ModelObject
|
||||
/// Center the current ModelObject to origin by translating the ModelVolumes
|
||||
void center_around_origin();
|
||||
|
||||
/// Get the matrix, that, when applied, centers the bounding box in all 3 coordinate directions
|
||||
TransformationMatrix get_trafo_to_center() const;
|
||||
|
||||
/// Translate the current ModelObject by translating ModelVolumes with (x,y,z) units.
|
||||
/// This function calls translate(coordf_t x, coordf_t y, coordf_t z) to translate every TriangleMesh in each ModelVolume.
|
||||
/// \param vector Vectorf3 the translation vector
|
||||
@ -388,6 +391,11 @@ class ModelObject
|
||||
/// \param axis Axis the axis to be rotated around
|
||||
void rotate(double angle, const Axis &axis);
|
||||
|
||||
/// Rotate the current ModelObject by rotating ModelVolumes.
|
||||
/// \param angle double the angle in radians
|
||||
/// \param axis Axis the axis to be rotated around
|
||||
void rotate(double angle, const Vectorf3 &axis);
|
||||
|
||||
/// Rotate the current ModelObject by rotating ModelVolumes to align the given vectors
|
||||
/// \param origin Vectorf3
|
||||
/// \param target Vectorf3
|
||||
|
Loading…
x
Reference in New Issue
Block a user