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:
bubnikv 2016-04-10 19:06:46 +02:00
parent c8ff517389
commit 7d54e28e30
4 changed files with 54 additions and 4 deletions

View file

@ -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 &center)
{