Rotating a polygon makes operator< disappear in visual c++ -
i'm new stackoverflow, sorry if format text wrong.
i have polygon want rotate given angle.
void polygon::rotateby( const float cosx, const float sinx ) { ( std::deque<polygonpoint>::iterator = point_list.begin(); != point_list.end(); ++i ) { i->x = (i->x * cosx) - (i->y * sinx); i->y = (i->x * sinx) + (i->y * cosx); } }
this has unexpected result:
polygon.rotateby(ccosx, csinx); std::priority_queue<edge, std::vector<edge>, comparepolysegmentsbyy> segments; for(std::deque<polygonpoint>::const_iterator = (polygon.point_list.cbegin() + 1); != polygon.point_list.cend(); ++i) { segments.push(edge(*(i-1), *i, i-1)); } segments.push(edge(polygon.point_list[ polygon.point_list.size() - 1 ], polygon.point_list[0], polygon.point_list.end() - 1));
the comparepolysegmentsbyy:
class comparepolysegmentsbyy { public: bool operator()(const edge& pol1, const edge& pol2) const { float t1 = pol1.getminy() - pol2.getminy(); if ( abs(t1) > eps ) return t1 > 0; else { if ( abs( pol1.getminx() - pol2.getminx() ) < eps ) { if ( abs ( pol1.getmaxy() - pol2.getmaxy() ) < eps ) return pol1.getmaxx() > pol2.getmaxx(); else return pol1.getmaxy() > pol2.getmaxy(); } else return pol1.getmaxx() > pol2.getminx(); } } };
i use comparepolysegmentsbyy order in priority queue. code gives error:
debug assertion failed: invalid operator<
when push edge in segments priority list. if comment out (delete) rotate statement (but not rotateby function) works fine! have no idea happening here.
Comments
Post a Comment