Questions tagged [polygon]

For issues relating to the creation, manipulation and rendering of polygons in graphical user interfaces.

A polygon is a two-dimensional figure that is bounded by a closed path composed of a finite sequence of straight line segments. Polygons are drawn and rendered in graphical user interfaces.

4546 questions
33
votes
6 answers

How to draw a n sided regular polygon in cartesian coordinates?

I have been trying to figure out how to write a simple program to compute the x,y points for creating a regular polygon of n sides. Can someone give me some code examples that don't use preexisting functions that draw polygons? I want to understand…
alphablender
  • 2,168
  • 5
  • 27
  • 42
31
votes
8 answers

Find Point in polygon PHP

i have a typical question with the Geometric datatype of mysql, polygon. I have the polygon data, in the form of an array of latitudes and longitudes, ex: [["x":37.628134, "y":-77.458334], ["x":37.629867, "y":-77.449021], ["x":37.62324, …
shasi kanth
  • 6,987
  • 24
  • 106
  • 158
31
votes
8 answers

How to draw transparent polygons?

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…
carrier
  • 32,209
  • 23
  • 76
  • 99
31
votes
3 answers

Determine if a point reside inside a leaflet polygon

Suppose I Draw a polygan using leaflet like in the follow demo: http://leaflet.github.io/Leaflet.draw/ My question is how I can determine if a given point reside inside the polygon or not.
Majdi Taleb
  • 731
  • 3
  • 9
  • 26
31
votes
9 answers

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…
Daren Thomas
  • 67,947
  • 40
  • 154
  • 200
30
votes
4 answers

Is there an easy and fast way of checking if a polygon is self-intersecting?

I have a System.Windows.Shapes.Polygon object, whose layout is determined completely by a series of points. I need to determine if this polygon is self-intersecting, i.e., if any of the sides of the polygon intersect any of the other sides at a…
GWLlosa
  • 23,995
  • 17
  • 79
  • 116
30
votes
3 answers

mongodb check if point is in polygon

mongo 2.6 I have some amount of stored polygons. And I have a point. I what to know if this point fits any of stored polygons document example { ..., "polygons" : [ [ 17.60083012593064, 78.18557739257812 ], [ 17.16834652544664, 78.19381713867188 ],…
user3806072
  • 303
  • 1
  • 3
  • 4
29
votes
6 answers

Google Maps v3 - Delete vertex on Polygon

Google Maps has the Drawing library to draw Polylines and Polygons and other things. Example of this functionality here: http://gmaps-samples-v3.googlecode.com/svn-history/r282/trunk/drawing/drawing-tools.html I want, when drawing and editing the…
James F
  • 554
  • 1
  • 9
  • 19
28
votes
1 answer

Converting a column of Polygons from string to GeoPandas geometry

I have a dataframe stored as csv file, one column of which is Polygon object. However, this column is stored as strings instead of GeoPandas geometry object. How can I convert this column to Geopandas geometry object so that I can perform geo…
xinyuanliu
  • 395
  • 1
  • 3
  • 5
28
votes
9 answers

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…
usr
  • 168,620
  • 35
  • 240
  • 369
27
votes
8 answers

Center of gravity of a polygon

I am trying to write a PHP function that will calculate the center of gravity of a polygon. I've looked at the other similar questions but I can't seem to find a solution to this. My problem is that I need to be able to calculate the center of…
mixkat
  • 3,883
  • 10
  • 40
  • 58
27
votes
3 answers

Efficient extraction of all sub-polygons generated by self-intersecting features in a MultiPolygon

Starting from a shapefile containing a fairly large number (about 20000) of potentially partially-overlapping polygons, I'd need to extract all the sub-polygons originated by intersecting their different "boundaries". In practice, starting from…
lbusett
  • 5,801
  • 2
  • 24
  • 47
27
votes
1 answer

How to draw rounded corner polygons on android canvas?

I need to draw polygons like triangle, trapezoid, pentagon, parallelogram, rhombus etc. It seems Path class is way to go, however i need these polygons have rounded corners and i also need to control the amount of the rounding.
user65721
  • 2,833
  • 3
  • 19
  • 28
27
votes
2 answers

Initializing Half-edge data structure from vertices

I'm working on implementing various subdivision algorithms (such as catmull-clark); to do this efficiently requires a good way to store information about a grid of tesselated polygons. I implemented the half-edge data structure as outlined by…
26
votes
5 answers

How to get list of points inside a polygon in python?

I searched a lot and cant find any practical answer to my question. I have a polygon. For example: [(86, 52), (85, 52), (81, 53), (80, 52), (79, 48), (81, 49), (86, 53), (85, 51), (82, 54), (84, 54), (83, 49), (81, 52), (80, 50), (81, 48), …
Farshid Ashouri
  • 16,143
  • 7
  • 52
  • 66