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
53
votes
7 answers

Largest circle inside a non-convex polygon

How can I find the largest circle that can fit inside a concave polygon? A brute force algorithm is OK as long as it can handle polygons with ~50 vertices in real-time.
Plow
  • 4,001
  • 3
  • 20
  • 21
48
votes
11 answers

Random points inside a parallelogram

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 preferred. Generating…
Andres
  • 1,875
  • 1
  • 19
  • 28
47
votes
6 answers

Algorithm to generate random 2D polygon

I'm not sure how to approach this problem. I'm not sure how complex a task it is. My aim is to have an algorithm that generates any polygon. My only requirement is that the polygon is not complex (i.e. sides do not intersect). I'm using Matlab for…
s5s
  • 11,159
  • 21
  • 74
  • 121
47
votes
3 answers

Calculate overlapped area between two rectangles

I want to calculate the overlapped area "THE GRAY REGION" between red and blue rectangles. Each rectangle is defined by its four corner coordinates. The resulted unit of the overlapped area is unit square. I could not imagine how can I do it? Any…
Eric Bal
  • 1,115
  • 3
  • 12
  • 16
46
votes
5 answers

How to create a shapely Polygon from a list of shapely Points?

I want to create a polygon from shapely points. from shapely import geometry p1 = geometry.Point(0,0) p2 = geometry.Point(1,0) p3 = geometry.Point(1,1) p4 = geometry.Point(0,1) pointList = [p1, p2, p3, p4, p1] poly =…
Sounak
  • 4,803
  • 7
  • 30
  • 48
42
votes
4 answers

Checking if a point is inside a polygon

I have a class describing a Point (has 2 coordinates x and y) and a class describing a Polygon which has a list of Points which correspond to corners (self.corners) I need to check if a Point is in a Polygon Here is the function that is supposed to…
Helena
  • 921
  • 1
  • 15
  • 24
39
votes
8 answers

Google Maps v3: check if point exists in polygon

I am looking to find a way of checking if a point exists inside a polygon in Google Maps v3 (JavaScript). I've searched everywhere and the only solutions I have found so far have been to do with getting the bounds of the polygon, but the code shown…
Bob-ob
  • 1,560
  • 4
  • 18
  • 34
39
votes
11 answers

How to draw polygons with Python?

I have input values of x, y coordinates in the following format: [[1,1], [2,1], [2,2], [1,2], [0.5,1.5]] I want to draw polygons, but I don't know how to draw them! Thanks
W.Fan
  • 407
  • 1
  • 4
  • 3
39
votes
7 answers

Calculate coordinates of a regular polygon's vertices

I am writing a program in which I need to draw polygons of an arbitrary number of sides, each one being translated by a given formula which changes dynamically. There is some rather interesting mathematics involved but I am stuck on this…
Nobody
  • 4,731
  • 7
  • 36
  • 65
38
votes
9 answers

How to determine if a point is inside a 2D convex polygon?

I have a convex polygon (typically just a rotated square), and I know all of 4 points. How do I determine if a given point (yellow/green) is inside the polygon? EDIT: For this particular project, I don't have access to all of the libraries of the…
NPike
  • 13,136
  • 12
  • 63
  • 80
38
votes
6 answers

How to attach a simple data.frame to a SpatialPolygonDataFrame in R?

I have (again) a problem with combining data frames in R. But this time, one is a SpatialPolygonDataFrame (SPDF) and the other one is usual data.frame (DF). The SPDF has around 1000 rows the DF only 400. Both have a common column, QDGC Now, I tried…
Jens
  • 2,363
  • 3
  • 28
  • 44
37
votes
6 answers

Simplified (or smooth) polygons that contain the original detailed polygon

I have a detailed 2D polygon (representing a geographic area) that is defined by a very large set of vertices. I'm looking for an algorithm that will simplify and smooth the polygon, (reducing the number of vertices) with the constraint that the…
mbrenig
  • 577
  • 1
  • 6
  • 11
37
votes
4 answers

sp::over() for point in polygon analysis

I have a shapefile named "ind_adm" and a SpatialPointsDataFrame called "pnts". The "pnts" contains points generated at random, and some of the points overlap with the polygon. See picture below. Now, I want do do a point in polygon analysis, i.e. I…
DotPi
  • 3,977
  • 6
  • 33
  • 53
36
votes
4 answers

Polygon enclosing a set of points

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…
Laurent K
  • 3,503
  • 3
  • 30
  • 36
35
votes
10 answers

Polygon Drawing and Getting Coordinates with Google Map API v3

I'm trying to develop an application by using Google Maps API v3. What I'm trying to do is; first let the user draw a polygon on a Google Map and get his/her polygon's coordinates and save them into a database. I will then show the user saved…
Burak Erdem
  • 19,630
  • 7
  • 36
  • 56