polygon

What is the quickest way to find the shortest cartesian distance between two polygons

Hi, I have 1 red polygon say and 50 randomly placed blue polygons - they are situated in geographical 2D space. What is the quickest/speediest algorithim to find the the shortest distance between a red polygon and its nearest blue polygon? Bear in mind that it is not a simple case of taking the points that make up the vertices of the ...

Is there an efficient\easy way to draw a concave polygon in Direct3d

I'm trying to draw a polygon using c# and directx All I get is an ordered list of points from a file and I need to draw the flat polygon in a 3d world. I can load the points and draw a convex shape using a trianglefan and drawuserprimitives. This obviously leads to incorrect results when the polygon is very concave (which it may be). ...

Algorithm for unique find edges from polygon mesh

I'm looking for a good algorithm that can give me the unique edges from a set of polygon data. In this case, the polygons are defined by two arrays. One array is the number of points per polygon, and the other array is a list of vertex indices. I have a version that is working, but performance gets slow when reaching over 500,000 polys....

Point in Polygon aka hit test

What's your best, most elegant 2D "point inside polygon" or Polygon.contains(p:Point) algorithm? Edit: There may be different answers for floats vs integers. Primary goal is speed. ...

Random points inside a Polygon

I have a 4 side convex Polygon defined by 4 points in 2D, and I want to be able to generate random points inside it. If it really simplifies the problem, I can limit the polygon to a parallelogram, but a more general answer is prefered. Generating random points until one is inside the polygon wouldn't work because it's really unpredict...

Comparing Polygons for Similarity

What are the usual methods to compare two polygons for similarity? Vertices are in 2D. ...

Convert Bitmap to Polygon - (Reverse-Rasterizing)

Given a bitmap image with some blots of solid color on it, what algorithm would you employ to construct polygons in the same shape as the blots? This can be done in multiple steps: a high-resolution polygon could be later cut down by a best fit algorithm. Bonus points if you can tell me how to cut the resulting polygons into convex com...

What is the fastest way to find the point of intersection between a ray and a polygon?

Pretty much as the question asks. Answers preferably in pseudo code and referenced. The correct answer should value speed over simplicity. ...

What happened to the python bindings for CGAL?

I found the Computational Geometry Algorithms Library in my search for an algorithm to decompose a concave polygon into the minimum number of convex components. Links off the site and numerous google results indicate there are python bindings for it, which would be really handy, but all the links are dead! What happened to it? Where c...

How do you draw transparent polygons with Python?

I'm using PIL (Python Imaging Library). I'd like to draw transparent polygons. It seems that specifying a fill color that includes alpha level does not work. Are their workarounds? If it can't be done using PIL I'm willing to use something else. If there is more than one solution, then performance should be factored in. The drawing...

How can I form polygons from lines

I have a bunch of 2-dimensional lines, whose start and end points are known. The lines might occasionally cross each other, or one line might end in the middle of another line. I need to form polygons from this mesh of lines. If necessary, I can ensure that the left side of all lines are inside their polygons. ...

3D Polygons in Python

As far as I am aware there is no inbuilt polygon functionality for Python. I want to create a 3D map and figured that polygons would be the best way to go about it. Not wanting to reinvent the wheel I did some googling and found that there's a lot of Python stuff out there, but I couldn't find what I wanted. Thus before I reinvent the w...

How do determine if a polygon is complex/convex/nonconvex?

From the man page for XFillPolygon · If shape is Complex, the path may self-intersect. Note that con‐ tiguous coincident points in the path are not treated as self- intersection. · If shape is Convex, for every pair of points inside the polygon, the line segment connecting them does not i...

Best Algorithm to find the edges (polygon) of vertices

I have a large array of vertices, some of them are edges, some are redundant (inside the shape) and I want to remove those. The simplest algorithm I could think of is checking one by one if they hit the shape formed by the others. But it should be a very slow algorithm. I thought about picking one from the edge (the one farthest from o...

Find the number of internal angles of a polygon, bigger than 180º

How can I find the number of internal angles of a polygon, bigger than 180º, having only the vertices of the polygon? For each vertex I want always the internal angle, not the external. Thanks from Brazil. ...

Math help - Can't rotate something (knowing Java would be a plus)

Okay I'm trying to rotate a Java Polygon based on it's original position of angle 0. x, and y end up being converted to an int at the end of me using them, so I could understand not seeing some change, but when the difference in angles is big like 0 to 180 I think I should see something. I've been at this for a little while and can't t...

Finding an axis-aligned rectangle inside a polygon

I am looking for a good algorithm to find an axis-aligned rectangle inside a (not necessarily convex) polygon. A maximal rectangle would be nice, but is not necessary - any algorithm that can find a "fairly good" rectangle would be fine. The polygon may also have holes, but any pointers to algorithms that only work for convex or simple ...

Minimize Polygon Vertices

What is a good algorithm for reducing the number of vertices in a polygon without changing the way it looks very much? Input: A polygon, represented as a list of points, with way too many verticies: raw input from the mouse, for example. Output: A polygon with much fewer verticies that still looks a lot like the original: something usa...

Searching a database of coordinate-bound data for an arbitrary polygonal area

I have a relational database where each entry is marked as a dot with latitude/longitude coordinates. I give the user the ability to mark an arbitrary polygon on a map, and want to return all entries that are within the polygonal shape. What would be the best way to achieve this? Also, it might be worth to point out that small errors ...

Ray-Polygon Intersection Point on the surface of a sphere

I have a point (Lat/Lon) and a heading in degrees (true north) for which this point is traveling along. I have numerous stationary polygons (Points defined in Lat/Lon) which may or may not be convex. My question is, how do I calculate the closest intersection point, if any, with a polygon. I have seen several confusing posts about Ray T...