Meged with release_candidate_1_3

This commit is contained in:
bubnikv 2016-09-12 11:29:39 +02:00
commit 9fcc8fe9ae
59 changed files with 4622 additions and 953 deletions

View file

@ -30,6 +30,19 @@ 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) {
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)
{
@ -89,15 +102,33 @@ MultiPoint::bounding_box() const
return BoundingBox(this->points);
}
void
bool
MultiPoint::has_duplicate_points() const
{
for (size_t i = 1; i < points.size(); ++i)
if (points[i-1].coincides_with(points[i]))
return true;
return false;
}
bool
MultiPoint::remove_duplicate_points()
{
for (size_t i = 1; i < this->points.size(); ++i) {
if (this->points.at(i).coincides_with(this->points.at(i-1))) {
this->points.erase(this->points.begin() + i);
--i;
size_t j = 0;
for (size_t i = 1; i < points.size(); ++i) {
if (points[j].coincides_with(points[i])) {
// Just increase index i.
} else {
++ j;
if (j < i)
points[j] = points[i];
}
}
if (++ j < points.size()) {
points.erase(points.begin() + j, points.end());
return true;
}
return false;
}
void