Pablote
Pablote

Reputation: 5083

Area that contains points?

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.

Upvotes: 3

Views: 411

Answers (3)

Martin Beckett
Martin Beckett

Reputation: 96119

If you are coding in C/C++ (or understand them) this is an excellent source of geometry algorithms - both source and explanation.

Upvotes: 0

MarkusQ
MarkusQ

Reputation: 21950

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.

Upvotes: 3

Thomas
Thomas

Reputation: 181715

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.

Upvotes: 7

Related Questions