diff options
author | bubnikv <bubnikv@gmail.com> | 2016-09-13 14:30:00 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-09-13 14:30:00 +0300 |
commit | 620c6c7378c4799980f63794669548c104b9bcea (patch) | |
tree | fc7aea3342539018bb19d27abd1144956eb00b4d /xs/src/libslic3r/BoundingBox.cpp | |
parent | a5b7f14dfa291039fd6971a356efd011fab84440 (diff) |
Ported from the playground branch. Various documentation and optimization.
Diffstat (limited to 'xs/src/libslic3r/BoundingBox.cpp')
-rw-r--r-- | xs/src/libslic3r/BoundingBox.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp index 1116d2dcb..c16d92f4e 100644 --- a/xs/src/libslic3r/BoundingBox.cpp +++ b/xs/src/libslic3r/BoundingBox.cpp @@ -68,6 +68,26 @@ BoundingBox::polygon() const return p; } +BoundingBox BoundingBox::rotated(double angle) const +{ + BoundingBox out; + out.merge(this->min.rotated(angle)); + out.merge(this->max.rotated(angle)); + out.merge(Point(this->min.x, this->max.y).rotated(angle)); + out.merge(Point(this->max.x, this->min.y).rotated(angle)); + return out; +} + +BoundingBox BoundingBox::rotated(double angle, const Point ¢er) const +{ + BoundingBox out; + out.merge(this->min.rotated(angle, center)); + out.merge(this->max.rotated(angle, center)); + out.merge(Point(this->min.x, this->max.y).rotated(angle, center)); + out.merge(Point(this->max.x, this->min.y).rotated(angle, center)); + return out; +} + template <class PointClass> void BoundingBoxBase<PointClass>::scale(double factor) { @@ -163,6 +183,26 @@ BoundingBox3Base<PointClass>::size() const } template Pointf3 BoundingBox3Base<Pointf3>::size() const; +template <class PointClass> double +BoundingBoxBase<PointClass>::radius() const +{ + double x = this->max.x - this->min.x; + double y = this->max.y - this->min.y; + return 0.5 * sqrt(x*x+y*y); +} +template double BoundingBoxBase<Point>::radius() const; +template double BoundingBoxBase<Pointf>::radius() const; + +template <class PointClass> double +BoundingBox3Base<PointClass>::radius() const +{ + double x = this->max.x - this->min.x; + double y = this->max.y - this->min.y; + double z = this->max.z - this->min.z; + return 0.5 * sqrt(x*x+y*y+z*z); +} +template double BoundingBox3Base<Pointf3>::radius() const; + template <class PointClass> void BoundingBoxBase<PointClass>::translate(coordf_t x, coordf_t y) { |