diff options
author | bubnikv <bubnikv@gmail.com> | 2016-09-12 14:52:31 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-09-12 14:52:31 +0300 |
commit | 73cbb4b5dceab3e39b0a5d92d27c1fe52f3b3116 (patch) | |
tree | 9b7c1db838f828993d21383eebf0ba7de15ae74d | |
parent | 9a83d4e8d59e88cfb0a4d23709dbf03b91c96027 (diff) |
some optimizations of Point rotation
-rw-r--r-- | xs/src/libslic3r/BoundingBox.hpp | 2 | ||||
-rw-r--r-- | xs/src/libslic3r/Point.cpp | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/xs/src/libslic3r/BoundingBox.hpp b/xs/src/libslic3r/BoundingBox.hpp index 4d0c1fe36..136ba1f8c 100644 --- a/xs/src/libslic3r/BoundingBox.hpp +++ b/xs/src/libslic3r/BoundingBox.hpp @@ -94,7 +94,7 @@ inline bool operator!=(const BoundingBoxBase<VT> &bb1, const BoundingBoxBase<VT> template<typename VT> inline bool empty(const BoundingBoxBase<VT> &bb) { - return bb.min.x > bb.max.y || bb.min.y > bb.max.y; + return bb.min.x > bb.max.x || bb.min.y > bb.max.y; } template<typename VT> diff --git a/xs/src/libslic3r/Point.cpp b/xs/src/libslic3r/Point.cpp index d7819bce2..e3c7b2262 100644 --- a/xs/src/libslic3r/Point.cpp +++ b/xs/src/libslic3r/Point.cpp @@ -72,8 +72,10 @@ Point::rotate(double angle, const Point ¢er) double cur_y = (double)this->y; double s = sin(angle); double c = cos(angle); - this->x = (coord_t)round( (double)center.x + c * (cur_x - (double)center.x) - s * (cur_y - (double)center.y) ); - this->y = (coord_t)round( (double)center.y + c * (cur_y - (double)center.y) + s * (cur_x - (double)center.x) ); + double dx = cur_x - (double)center.x; + double dy = cur_y - (double)center.y; + this->x = (coord_t)round( (double)center.x + c * dx - s * dy ); + this->y = (coord_t)round( (double)center.y + c * dy + s * dx ); } bool @@ -386,8 +388,10 @@ Pointf::rotate(double angle, const Pointf ¢er) double cur_y = this->y; double s = sin(angle); double c = cos(angle); - this->x = center.x + c * (cur_x - center.x) - s * (cur_y - center.y); - this->y = center.y + c * (cur_y - center.y) + s * (cur_x - center.x); + double dx = cur_x - center.x; + double dy = cur_y - center.y; + this->x = center.x + c * dx - s * dy; + this->y = center.y + c * dy + s * dx; } Pointf |