Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Area that contains points?

Tags:

algorithm

Does anyone know if there's an algorithm for this? I have several 2D points. I need to find a list of points that when you draw a line from point n to point n+1 you end up with an area that contains all the points. If I could attach an image, I could explain myself better. Thanks in advance.

like image 334
Pablote Avatar asked Aug 31 '25 22:08

Pablote


2 Answers

What you are looking for is probably the convex hull. Wikipedia has a picture. There are several algorithms to compute the convex hull. The Graham scan probably provides the best balance between performance and ease of implementation.

like image 148
Thomas Avatar answered Sep 03 '25 20:09

Thomas


What you are asking for sounds like what's called the convex hull. Google that for lots of information.

If the points don't have to be members of the set, just find the bounding box.

If the collection doesn't have to be convex, just find the center of mass of the cloud, order the points (say, clockwise) around this, and you'll have an irregular star.

like image 25
MarkusQ Avatar answered Sep 03 '25 18:09

MarkusQ