Fixed concave_points() and convex_points() after recent change of ccw_angle()
This commit is contained in:
parent
7253dc699a
commit
4fc955a0fd
@ -226,20 +226,23 @@ Polygon::wkt() const
|
||||
return wkt.str();
|
||||
}
|
||||
|
||||
// find all concave vertices (i.e. having an internal angle greater than the supplied angle) */
|
||||
void
|
||||
Polygon::concave_points(double angle, Points* points) const
|
||||
{
|
||||
angle = 2*PI - angle;
|
||||
|
||||
// check whether first point forms a concave angle
|
||||
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) >= angle)
|
||||
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) <= angle)
|
||||
points->push_back(this->points.front());
|
||||
|
||||
// check whether points 1..(n-1) form concave angles
|
||||
for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) {
|
||||
if (p->ccw_angle(*(p-1), *(p+1)) >= angle) points->push_back(*p);
|
||||
if (p->ccw_angle(*(p-1), *(p+1)) <= angle) points->push_back(*p);
|
||||
}
|
||||
|
||||
// check whether last point forms a concave angle
|
||||
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) >= angle)
|
||||
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) <= angle)
|
||||
points->push_back(this->points.back());
|
||||
}
|
||||
|
||||
@ -249,20 +252,23 @@ Polygon::concave_points(Points* points) const
|
||||
this->concave_points(PI, points);
|
||||
}
|
||||
|
||||
// find all convex vertices (i.e. having an internal angle smaller than the supplied angle) */
|
||||
void
|
||||
Polygon::convex_points(double angle, Points* points) const
|
||||
{
|
||||
angle = 2*PI - angle;
|
||||
|
||||
// check whether first point forms a convex angle
|
||||
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) <= angle)
|
||||
if (this->points.front().ccw_angle(this->points.back(), *(this->points.begin()+1)) >= angle)
|
||||
points->push_back(this->points.front());
|
||||
|
||||
// check whether points 1..(n-1) form convex angles
|
||||
for (Points::const_iterator p = this->points.begin()+1; p != this->points.end()-1; ++p) {
|
||||
if (p->ccw_angle(*(p-1), *(p+1)) <= angle) points->push_back(*p);
|
||||
if (p->ccw_angle(*(p-1), *(p+1)) >= angle) points->push_back(*p);
|
||||
}
|
||||
|
||||
// check whether last point forms a convex angle
|
||||
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) <= angle)
|
||||
if (this->points.back().ccw_angle(*(this->points.end()-2), this->points.front()) >= angle)
|
||||
points->push_back(this->points.back());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user