polygon

Converting indexed polygons to unindexed ones. Several problems have cropped up.

Yet again I have some questions regarding polygon algorithms. I'll try to explain my problem: I am using a subset of a third party library called Geometric Tools(GT) to perform boolean operations on my polygons. To accomplish this I have to convert my internal polygon format to the format GT uses. Our internal polygon format consists...

Algorithm to merge adjacent rectangles into polygon

I guess that my problem is related to "convex hull", but no the same. All shapes in the drawing are rectangles with same width and height. Many are adjacent to each other. I want to combine those adjacent rectangles into polygons. Unlike "convex hull", the resuled polygons could be "hollow" inside. Is there any open source algorithm av...

how to determine polygon rotation angle

I am writing a program (.net) to create a stadium style layout and need to determine the angle of rotation for each polygon compared to the horizontal. This is so i can construct the contents of the polygon and also rotate this correctly to fit inside. Given the below image as an example to simulate each variant of the facing direction...

How to determine a diagonal is in or out of a concave polygon?

The diagonal (a diagonal is a segment connecting nonadjacent vertices) of a concave (non-convex) polygon can be completely in or out of the polygon(or can intersect with the edges of polygon). How to determine whether it is completely in the polygon?(a method without point-in-polygon test). ...

Concave polygon drawing

For drawing complex concave polygons with OpenGL, is it better to tesselate it into triangles, or use the stencil buffer? I'm guessing the stencil buffer would be faster for a single frame, but triangulation would be better for multiple frames if the polygon doesn't change. However, I haven't actually tried it, so I don't know. ...

How do I determine if two convex polygons intersect?

Suppose there are a number of convex polygons on a plane, perhaps a map. These polygons can bump up against each other and share an edge, but cannot overlap. To test if two polygons P and Q overlap, first I can test each edge in P to see if it intersects with any of the edges in Q. If an intersection is found, I declare that P and Q...

how to sketch a polygon in a matrix or binary image in order to use image processing functions?

I'm developing a matlab program in which I uses polygons(concave or convex). I need to use image processing functions like imdilate or imerode and etc on the polygons. To this end, I should convert my polygons to image. I wonder whether there is a way to sketch a polygon directly in a binary matrix (1's for foreground and 0's for backgro...

Polygon enclosing a set of points

Hello folks, I have a set S of points (2D : defined by x and y) and I want to find P, the smallest (meaning : with the smallest number of points) polygon enclosing all the points of the set, P being an ordered subset of S. Are there any known algorithms to compute this? (my lack of culture in this domain is astonishing...) Thanks for ...

distance from point within a polygon to polygon edge

I am working with a huge area, 7 states of forest and nonforest using the NLCD data. Within some of the forested areas is a plot (this is my master's thesis I am working on). I have stumped everyone I have asked with this large dataset but we are certain there is a resolution out there. The forest/nonforest area is a signed and discrete ...

Polygon triangulation

Hey, I am working on nesting of sheet metal parts and am implementing Minkowski Sums to find No Fit Polygons for nesting. The problem is I can give only convex sets as input to the code which calculates Minkowski sums for me. Hence I need to break a concave polygon, with holes into Convex sets. I am open to triangulation also, but I am ...

What are some recommended frameworks for manipulating spatial data in C++?

What are some recommended frameworks for manipulating spatial data in C++? I'm looking for a polygon object, point object, and some operations like union, intersection, distance, and area. I need to enter coordinates in WGS84 (lon,lat) and get area in square km. I would prefer a free/open source framework, but am open to suggestion...

How to represent a polygon with hole(s) ?

It's usually popular to work with polygons with their vertices sorted CW or CCW in vectors(2*1 or 1*2 matrices). However, how to state polygons with holes in vectors? I'm going to apply various process on these polygons, so I want a way of representing with which I could work easily or efficiently.(i.e how to state that kind of polygon...

OpenGL background dissappears with certain Polygon Modes

I am creating a simple gradient background by drawing a quad as follows: glMatrixMode GL.GL_PROJECTION glLoadIdentity glMatrixMode GL.GL_MODELVIEW glLoadIdentity ***glPolygonMode GL_FRONT_AND_BACK, GL_LINE*** glDisable glcDepthTest glBegin bmQuads glColor4d 1, 0, 0, 1 glVertex2i -1, -1 glVertex2i 1, -1 ...

See if lat / long falls within a polygon using mysql

I have the created the table below CREATE TABLE geom (g GEOMETRY); and have inserted many rows, example below: INSERT INTO geom (g) VALUES(PolygonFromText('POLYGON(( 9.190586853 45.464518970, 9.190602686 45.463993916, 9.191572471 45.464001929, 9.191613325 45.463884676, 9.192136130 45.463880767, 9.192111509 45.464095594, 9.192427961 4...

How can I access the points of the polygon stored in Postgres using Libpqxx?

I want to retrieve the points of a polygon that are stored in the postgres db. The contents of the db are: polygonid |vertices -----------+--------------------------------------------------------------------- 2 |((1,0),(1.5,-1),(2,-1),(2,1),(1,1),(0,0),(0,2),(3,2),(3,-2),(1,-2)) 4 | ((3,3),(4,4),(5,5)) The vertices ...

How can I create a polygon using fields in PostgreSQL?

I have 8 real values in a table that I'd like to combine into a polygon. I haven't been able to figure out how to create a polygon using these values though. I keep trying variations of SELECT polygon(lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4) FROM table; but keep getting errors about the polygon function not existing or an invalid inpu...

An algorithm for inflating/deflating (offsetting, buffering) polygons

UPDATE: the math term for what I'm looking for is actually inward/outward polygon offseting. +1 to balint for pointing this out. The alternative naming is polygon buffering. Before I start developing my own solution from scratch, does anyone know of any good source for an algorithm that can inflate a polygon, something similar to this: ...

How to test if a point is inside of a convex polygon in 2D integer coordinates?

The polygon is given as a list of Vector2I objects (2 dimensional, integer coordinates). How can i test if a given point is inside? All implementations i found on the web fail for some trivial counter-example. It really seems to be hard to write a correct implementation. The language does not matter as i will port it myself. ...

How to determine if a list of polygon points are in clockwise order?

Having a list of points, how do I find if they are in clockwise order? For example: point[0] = (5,0) point[1] = (6,4) point[2] = (4,5) point[3] = (1,5) point[4] = (1,0) would say that it is anti-clockwise (counter-clockwise for some people). ...

Stop bing maps simplifying polygons

Bing maps currently simplifies each polygon shape that gets put on the map. While that's good for most things, I need to show the full resolution polygons and I'll sort out the simplification myself. Any ideas on how to do this, I can't seem to find a way to turn it off and finding documentation on Bing/live/VE/MS/whatever maps is a ni...