Ok Paul, here it is:
Code:class CGlobalStorage { public: CGlobalStorage(); virtual ~CGlobalStorage(); ... std::vector<myPoint> points; std::vector<myPoint> hull; }; CGlobalStorage gs; int main(int argc, char* argv[]) { // This just fills gs.points with some random points CGeomUtils::generateRandomPoints(1000, gs.points, maxX, maxY); CHull::computeHull(gs.points, gs.hull); } typedef struct _myPoint { int x; int y; _myPoint() : x(0), y(0) {} _myPoint(int _x, int _y) : x(_x), y(_y) {} _myPoint(const _myPoint & aP) : x(aP.x), y(aP.y) {} } myPoint; void CGeomUtils::sortByAngleRelativeTo(const myPoint & relativeTo, std::vector<myPoint>::iterator start, std::vector<myPoint>::iterator end) { CGeomUtils::relativePoint = relativeTo; std::sort(start, end, CGeomUtils::sortByAngleRelativeTo_callback); } bool CGeomUtils::sortByAngleRelativeTo_callback(myPoint a, myPoint b) { double angle1 = CGeomUtils::getAngleRelative(CGeomUtils::relativePoint, a); double angle2 = CGeomUtils::getAngleRelative(CGeomUtils::relativePoint, b); if (CGeomUtils::IS_EQUIV(angle1, angle2)) return false; if (angle1 < angle2) return true; return false; }




Reply With Quote