Point To Polygon

Started by
11 comments, last by Postie 11 years, 7 months ago
hey
does anyone know how to create a polygon from points? i tried googling and looking through my graphics programming books but found nothing.... I can't use any library to do this need the algorithm it self.
thanks
Advertisement
What does "a polygon from points" mean? You have the corners of the polygon? Also in what context?
You mean like use the corners to color in pixels? Google scanline rasterization
i have simply array of points (x,y). and make polygon from that
Typically a polygon IS given by its vertices ("corners"). So mathematically speaking you already have a polygon. Without further context you question doesn't make much sense.
the points are not in order
A simple polygon you can make from a collection of points is a convex hull. The advantage of this is there is a unique solution for the set of input points, but it discards any points that are internal to the polygon. There are quite a few different algorithms for calculating a convex hull (of varying complexity and performance), so have a quick google and find an algorithm that is up to your level of expertise.

[attachment=11038:points1.png]

If you need to include all vertices, the polygon is going to be a concave hull, and you start to run into problems. Unless you know there are definite constraints on the way the vertices link up, like say a maximum distance or angle between vertices, you quickly discover there are many solutions for even a small number of vertices, doubly so if you allow self-intersection.

[attachment=11039:points2.png]
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler

If you need to include all vertices, the polygon is going to be a concave hull, and you start to run into problems. Unless you know there are definite constraints on the way the vertices link up, like say a maximum distance or angle between vertices, you quickly discover there are many solutions for even a small number of vertices, doubly so if you allow self-intersection.


this is what i need "concave hull". is there any algorithms..?
can anyone recommend math book or game programming book that teaches these things? thanks.
or answer to this post will do as well :)

can anyone recommend math book or game programming book that teaches these things? thanks.
or answer to this post will do as well smile.png


Well, it depends on how you want them connected. Does it matter?

This topic is closed to new replies.

Advertisement