Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate a bounding polygon?

I have a cloud of 2D points and I would like to calculate the perimeter of a polygon which encompasses all of them.

Is there a name for this mathematical process which I can Google or can someone tell me how to start thinking about the problem, please?

like image 451
Matt W Avatar asked Sep 17 '13 08:09

Matt W


2 Answers

You're probably looking for the convex hull and for convex hull algorithms.

One of the simplest 2D algorithms is the Gift wrapping algorithm. To quote Wikipedia:

It has O(nh) time complexity, where n is the number of points and h is the number of points on the convex hull. Its real-life performance compared with other convex hull algorithms is favorable when n is small or h is expected to be very small with respect to n. In general cases the algorithm is outperformed by many others.

So depending on the size of your problem, you might need to take a look on the algorithms page linked above in order to find more advanced approaches.

like image 176
cyroxx Avatar answered Nov 11 '22 21:11

cyroxx


One well-defined such polygon is the convex hull. There are several well-studied algorithms for finding convex hulls.

like image 29
svk Avatar answered Nov 11 '22 19:11

svk