Getting the bounding box of a vector of points?
问题 I have a vector of points stored in a std::vector instance. I want to calculate the bounding box of these points. I've tried with this code: bool _compare1(ofPoint const &p1, ofPoint const &p2) { return p1.x < p2.x && p1.y < p2.y; } bool _compare4(ofPoint const &p1, ofPoint const &p2) { return p1.x > p2.x && p1.y > p2.y; } vector<ofPoint> points; // ... if(points.size()>1) { ofPoint p_min = *std::min_element(points.begin(), points.end(), &_compare1); ofPoint p_max = *std::min_element(points