Lay flat - rotation is now done in one go directly about the necessary axis

This commit is contained in:
Lukas Matena 2018-08-21 15:40:11 +02:00
parent d197a5149a
commit 86b67bbd42
8 changed files with 62 additions and 27 deletions

View file

@ -725,7 +725,7 @@ void ModelObject::scale(const Pointf3 &versor)
this->invalidate_bounding_box();
}
void ModelObject::rotate(float angle, const Axis &axis)
void ModelObject::rotate(float angle, const Pointf3& axis)
{
for (ModelVolume *v : this->volumes)
{

View file

@ -120,7 +120,7 @@ public:
void translate(const Vectorf3 &vector) { this->translate(vector.x, vector.y, vector.z); }
void translate(coordf_t x, coordf_t y, coordf_t z);
void scale(const Pointf3 &versor);
void rotate(float angle, const Axis &axis);
void rotate(float angle, const Pointf3& axis);
void transform(const float* matrix3x4);
void mirror(const Axis &axis);
size_t materials_count() const;

View file

@ -324,6 +324,17 @@ void TriangleMesh::translate(float x, float y, float z)
stl_invalidate_shared_vertices(&this->stl);
}
void TriangleMesh::rotate(float angle, Pointf3 axis)
{
if (angle == 0.f)
return;
axis = normalize(axis);
Eigen::Transform<float, 3, Eigen::Affine> m = Eigen::Transform<float, 3, Eigen::Affine>::Identity();
m.rotate(Eigen::AngleAxisf(angle, Eigen::Vector3f(axis.x, axis.y, axis.z)));
stl_transform(&stl, (float*)m.data());
}
void TriangleMesh::rotate(float angle, const Axis &axis)
{
if (angle == 0.f)

View file

@ -40,6 +40,7 @@ public:
void scale(const Pointf3 &versor);
void translate(float x, float y, float z);
void rotate(float angle, const Axis &axis);
void rotate(float angle, Pointf3 axis);
void rotate_x(float angle);
void rotate_y(float angle);
void rotate_z(float angle);