Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define bounding rectangle of an array of points

Tags:

javascript

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?

like image 523
nagymafla Avatar asked Sep 01 '25 22:09

nagymafla


1 Answers

Store the min and max of x and do the same to y. Now you have your rectangle.

like image 60
Adam Dymitruk Avatar answered Sep 04 '25 10:09

Adam Dymitruk