Skip to content

Instantly share code, notes, and snippets.

@Akira-Hayasaka
Last active December 10, 2019 07:56
Show Gist options
  • Save Akira-Hayasaka/012e407dc2ce18b2faa38a21180ae65b to your computer and use it in GitHub Desktop.
Save Akira-Hayasaka/012e407dc2ce18b2faa38a21180ae65b to your computer and use it in GitHub Desktop.
auto get_bbox = [](const vector<ofVec2f> pts) -> ofRectangle
{
auto xpair = std::minmax_element(pts.begin(), pts.end(),
[](const ofVec2f& a, const ofVec2f& b) {
return a.x < b.x;
});
auto ypair = std::minmax_element(pts.begin(), pts.end(),
[](const ofVec2f& a, const ofVec2f& b) {
return a.y < b.y;
});
return ofRectangle(
xpair.first->x, ypair.first->y,
xpair.second->x - xpair.first->x, ypair.second->y - ypair.first->y);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment