Created
December 2, 2019 19:05
-
-
Save companje/a1cab8bd67ef98ec101366de0e7b1895 to your computer and use it in GitHub Desktop.
getBounds from points
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rectangle getBounds(ArrayList<PVector> vv) { | |
if (vv.size()==0) return new Rectangle(); | |
float xMin = Float.POSITIVE_INFINITY; | |
float yMin = Float.POSITIVE_INFINITY; | |
float xMax = Float.NEGATIVE_INFINITY; | |
float yMax = Float.NEGATIVE_INFINITY; | |
for (int i=1; i<vv.size(); i++) { | |
xMin = min(xMin,vv.get(i).x); | |
yMin = min(yMin,vv.get(i).y); | |
xMax = max(xMax,vv.get(i).x); | |
yMax = max(yMax,vv.get(i).y); | |
} | |
Rectangle r = new Rectangle(); | |
r.setFrame(xMin,yMin,xMax-xMin,yMax-yMin); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment