Reputation: 267
I have a set of points in an array. All points have x and y coordinates. How can I get the bounding rectangle of this set? The "rectangle" object should have properties like x, y, width, height. Any ideas?
Upvotes: 4
Views: 1007
Reputation: 32521
Find max x in set, find min x in set. Find max y in set, find min y in set. There's your bounding rectangle...
Upvotes: 1
Reputation: 129782
Store the min and max of x and do the same to y. Now you have your rectangle.
Upvotes: 3