computational-geometry

What is the fastest algorithm to calculate the minimum distance between two sets of points?

喜你入骨 提交于 2019-12-17 03:42:28
问题 I want to find the minimum distance between two polygons. I have to find the minimum of shortest distance between each vertex of first shape with all of the vertices of the other one. Something like the Hausdorff Distance, but I need the minimum instead of the maximum. 回答1: Perhaps you should check out ( PDF warning! Also note that, for some reason, the order of the pages is reversed ) "Optimal Algorithms for Computing the Minimum Distance Between Two Finite Planar Sets" by Toussaint and

How do I efficiently determine if a polygon is convex, non-convex or complex?

强颜欢笑 提交于 2019-12-17 02:28:31
问题 From the man page for XFillPolygon: If shape is Complex , the path may self-intersect. Note that contiguous 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 intersect the path. If known by the client, specifying Convex can improve performance. If you specify Convex for a path that is not convex, the graphics results are undefined. If shape is Nonconvex , the path does

shortest distance through coordinates

无人久伴 提交于 2019-12-14 03:28:01
问题 I am given a set of point in the x-y plane ={(x1,y1),(x2,y2),.....(xn,yn)} and I am given two points a(xa,ya) and b(xb,yb) and asked to find the set of points that cover the shortest path. no connection between points are given. If I assume a connection to every other point.it will take a long time to compute these values for a weighted graph. Can someone tell me what reading I should do. what topic does this problem come under graph algorithms?!!(Is there any specific algorithm) I have been

Check whether Point lies strictly inside the triangle

一笑奈何 提交于 2019-12-13 23:15:34
问题 Given 3 integral coordinates of vertices of Triangle ABC and another integral coordinate P , how do I check if P strictly lies inside the triangle or not ? I know how to check if P is inside triangle or not using Area method i.e, Area ABC = Area ABP + Area ACP + Area BCP . But In this question, I want to P to be strictly inside the triangle. 回答1: There is lot approaches to check whether point lies inside triangle. The simplest ones, I think: 1) Check whether point is on the same side of all

Create a square polygon (random oriented) from midpoints in Python

蹲街弑〆低调 提交于 2019-12-13 21:01:01
问题 I have a midpoint (x,y) and i need to create a square polygon with random orientation using a 2D (random) planar rotation. def get_square_plot(x, y, side): return [(x-(side/2), y+(side/2)), (x+(side/2), y+(side/2)), (x+(side/2), y-(side/2)), (x-(side/2), y-(side/2))] This function creates the vertices of a square polygon without a specific orientation. I wish to improve this function adding the possibility to rotation randomly these vertices (and with a specific angle if is possible) 回答1: If

How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)

半腔热情 提交于 2019-12-13 16:42:19
问题 I am looking for a method, preferably in PHP, to analyze a group of polygons to detect the outer boundaries of the group. Specifically, this is for a Google Maps v3 application that renders territories. Each polygon in the territory is a ZIP Code. I'm trying to detect and draw only the territory boundary. Here's a mock-up of what I'm trying to accomplish: The challenges I face in solving this problem: ZIP Codes within each territory can be (and often are) non-contiguous (see the red and green

Tracking multi-touch movements inside the frame with transmitters and receivers

馋奶兔 提交于 2019-12-13 12:48:14
问题 The problem with tracking multi-touches (at least two finger touches) on the following frame device. White circles are LEDs and black circles are receivers. When user moves fingers inside this frame we can analyze which receivers received light from the LEDs and which has not received. Based on that we need to track movements of the fingers somehow. First problem that we has separate x and y coordinates. What is the effective way to combine them? Second problem concerns analyzing coordinates

Convex Hull in O(n) time if each coordinate of each point is a rational number

霸气de小男生 提交于 2019-12-13 12:33:09
问题 Show that the convex hull of n points in the plane can be computed in O(n) time if each coordinate of each point is a rational number of the form p/q , with bounded values for p and q. Note: This is a homework problem. I can just think of using Jarvis March by somehow avoiding the scan of all points. Maybe this can be done by throwing rays in fixed directions (using the rational condition) to check where the next point exists . 回答1: Don't use Jarvis March since it has time complexity of O(nh)

Ray casting point in polygon test for polygon with ray-aligned edges

十年热恋 提交于 2019-12-13 06:29:22
问题 I tried using the following code for the Even-Odd Rule from Wikipedia # x, y -- x and y coordinates of point # poly -- a list of tuples [(x, y), (x, y), ...] def isPointInPath(x, y, poly): num = len(poly) i = 0 j = num - 1 c = False for i in range(num): if ((poly[i][1] > y) != (poly[j][1] > y)) and \ (x < (poly[j][0] - poly[i][0]) * (y - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]): c = not c j = i return c Unfortuantely, it's giving wrong results for my simple rectilinear polygon

How to fill a closed poly-line with equidistant horizontal lines?

橙三吉。 提交于 2019-12-13 06:02:40
问题 I need to write and algorithm that fills closed poly-line with horizontal equidistant lines. I've done similar things with rectangles and circles , here is a code snippet for the latter: // circle parameters: center(point(0).x, point(0).y), radius int offsetX = point(0).x + radius; int offsetY = point(0).y + radius; for(int i = -radius; i < radius; i += spacing){ int ry = i; int rx = sqrt(double(radius*radius - ry*ry)); // the parameters are pair of coordinates of the horizontal line fl_line