polygon

Determine ordering of polygon 3D

Hello, I have a list of vertices 3D, creating a polygon. I need to triangulate it and i use the cutting ears algorithm. My polygons are non-convex, so i need to find the concave angles in the polygon. I also dont know wich orientation are my polygons ( clockwise or counter clocwise) Could anyone help me how to determine if is clockwise...

What is the fastest way to find the center of an irregularly shaped polygon?

I need to find a point that is a visual center of an irregularly shaped polygon. By visual center, I mean a point that appears to be in the center of a large area of the polygon visually. The application is to put a label inside the polygon. Here is a solution that uses inside buffering: http://proceedings.esri.com/library/userconf/pro...

How to partition a plane

Let's say I have a fixed number (X) of points, e.g. coordinates within a given plane (I think you can call it a 2-D point cloud). These points should be partitioned into Y polygons where Y < X. The polygons should not overlap. It would be wonderful if the polygons were konvex (like a Voronoi diagram). Imagine it like locations formin...

How to animate a polygon? (Read: Animate the contour to change shape)

Greetings! I am currently working on a Silverlight project and I would like to animate a simple polygon shape (a trapezoid actually). Specifically, I woudld like to move two of the four points dynamically after some event happened. I need / want to resize and move one of the parallel sides to another position. I admit I am rather new...

Reflections and other transformations with Java Polygons

Hi everyone, I'm working on a project that requires me to do simple geometrical transformations (translation, reflection over x and y axis) on some figures drawn on a Java applet. The previous guy working on the applet was drawing the figures from arrays representing the caretesian points for the vertices of each figure. I decided to...

VB6: Colour portions of points of a star

Hello I have found API functions to draw a star using VB6: what I need is to colour sections of each point of the star according to data-driven parameters: thus if the parameter passed is 1, I want to colour the part of the selected star point red up to 1/10th of its length measured from the circunference of the circle around which the ...

Determining if a point is on a road

If I have a polyline that describes a road and I know the road width at all parts, is there an algorithm I can use to determine if a point is on the road? I'm not entirely sure how to do this since the line itself has a width of 1px. thanks, Jeff ...

Silverlight - polygon scaling and clipping

I have a Canvas, to which I've added several thousand polygons. I would like to be able to zoom in (which I'm doing via a ScaleTransform. However I've been trying to use a Canvas.Clip as well to only draw a portion of the Canvas, but as soon as the ScaleTransform values are changed, the clipping stops working... <Canvas Grid.Row="...

Expanding a n-vertices polygon with a new data set to a n-vertices polygon

There is a simple polygon P1 with n vertices, n is small, let say 8. This polygon shall represent a perimeter of some set of 2D points. Next, we have another polygon, lets call it P2, also with max number of vertices n. P2 is close to P1, so it makes sense to draw a new polygon, P3, which will describe the area of P1 and P2 together. I...

Optimizing ActiveRecord Point-in-Polygon Search

Hello stackies. The following PiP search was built for a project that lets users find their NYC governmental districts by address or lat/lng (http://staging.placeanddisplaced.org). It works, but its kinda slow, especially when searching through districts that have complex polygons. Can anyone give me some pointers on optimizing this code...

Initializing a polygon in boost::geometry

I am new to the generic geometry library that is proposed for inclusion with boost: http://geometrylibrary.geodan.nl/ I have two vectors vector<int> Xb, Yb that I am trying to create a polygon from. I am trying to get something along the lines of the following code snippet: polygon_2d P; vector<double>::const_iterator xi; vector<...

Having trouble with ear clipping

The problem I have is coming up because I can't identify a a caved in triangle vs an ear that should actually be chopped off. How can I tell the difference between a convex and a concave triangle? ...

Find a point in a complex polygon

This polygon could be shaped like a C I tried the formula located here http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test however it doesn't actually correctly predict if the point is in the polygon. ...

How do I flip a polygon by flipping the array?

I have 2 arrays of ints I am using to create a polygon (that looks like a fish). What do I need to do to the arrays to flip the polygon horizontally? x = new int[] { 0, 18, 24, 30, 48, 60, 60, 54, 60, 48, 30, 24, 0 }; y = new int[] { 0, 18, 6, 0, 0, 12, 18, 24, 24, 36, 36, 30, 36 }; ...

Creating a polygon shape from a 2d tile array

I have a 2D array which just contains boolean values showing if there is a tile at that point in the array or not. This works as follows, say if array[5,6] is true then there is a tile at the co-ordinate (5,6). The shape described by the array is a connected polygon possibly with holes inside of it. Essentially all i need is a list of v...

How to intersect two polygons?

This seems non-trivial (it gets asked quite a lot on various forums), but I absolutely need this as a building block for a more complex algorithm. Input: 2 polygons (A and B) in 2D, given as a list of edges [(x0, y0, x1, y2), ...] each. The points are represented by pairs of doubles. I do not know if they are given clockwise, counter-cl...

Copy polygon to new location

How can I copy a polygon to a new location. I use e.isPopupTrigger() to select the polygon, but I dont know how to copy it. Is the function of copy similar to the function of translate? e.g. polygon.translate(x,y)? Thanks. EDITED: //this code doesnt work :-( if(e.getSource() == Copy){ Polygon copyPolygon = new Polygon(); copyPo...

How can I fill an actionscript 3 polygon with a solid color?

I'm building a map editor for a project and need to draw a hexagon and fill it with a solid color. I have the shape correct but for the life of me can't figure out how to fill it. I suspect it may be due to whether the thing is a Shape, Sprite or UIComponent. Here is what I have for the polygon itself: import com.Polygon; import mx.c...

PHP - Mask polygon over image

Hi Everyone (this is my first post), I am trying to figure a way of cropping a polygon out of an image. I have been reading other similar code. It seems that most code is based around the following process: -Resize the image to fit the width and height of the polygon shape, -Create a blank image of an unusual colour the same size, -O...

Polygon Intersection fails, collision "size" too big

OK, so I'm trying to make a simple asteroids clone. Everything works fine, except for the collision detection. I have two different versions, the first one uses java.awt.geom.Area: // polygon is a java.awt.Polygon and p is the other one final Area intersect = new Area(); intersect.add(new Area(polygon)); intersect.intersect(new Area(p....