mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Added optimized methods for point and polyline rotation.
Existing methods for rotation were optimized by calculating the sin/cos values once only. Added an operator- for points.
This commit is contained in:
parent
c8ff517389
commit
7d54e28e30
4 changed files with 54 additions and 4 deletions
|
@ -30,6 +30,20 @@ MultiPoint::translate(const Point &vector)
|
|||
this->translate(vector.x, vector.y);
|
||||
}
|
||||
|
||||
void
|
||||
MultiPoint::rotate(double angle)
|
||||
{
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
for (Points::iterator it = points.begin(); it != points.end(); ++it) {
|
||||
(*it).rotate(angle);
|
||||
double cur_x = (double)it->x;
|
||||
double cur_y = (double)it->y;
|
||||
it->x = (coord_t)round(c * cur_x - s * cur_y);
|
||||
it->y = (coord_t)round(c * cur_y + s * cur_x);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MultiPoint::rotate(double angle, const Point ¢er)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue