computational-geometry

Fast algorithm to find all points inside a rectangle

一笑奈何 提交于 2019-12-06 03:02:50
问题 Given a set of distinct points in 2D space, and a rectangle (coordinates of all four points, sides parallel with xy axis) how can I quickly find which points are inside the rectangle? I'm not interested in the basic solution of going through all points and seeing which one is inside the rectangle. What I'm looking for is an algorithm which will give me fast query times per rectangle. I don't care how much time I spend in the preprocessing step. What I do care is that after I process my data I

Identifying the original edge of a union polygon

我怕爱的太早我们不能终老 提交于 2019-12-06 02:36:50
问题 I have a lot of polygons, and after I do a union of all these polygons, I get a new, big polygon. The union algorithm is a black box and using third-party-library process, which I couldn't control, and neither can I hope to extract any information out kind of progress. Is there efficient way for me to know, for every edge of that big gigantic unionized polygon, which of it is belonging to which edge of the smaller polygon? A brute force way to solve this problem is to compare every edge of

A linear-time algorithm to find any vertex of a polygon visible from other vertex

折月煮酒 提交于 2019-12-06 01:49:54
问题 Suppose there is a polygon with no holes and self-intersections (i.e. a simple polygon) defined by n vertices. Choose a reflex vertex v of this polygon. I'd like to find any other vertex u of the same polygon which is "visible" from the vertex v . By visible I mean, that a line segment between v and u lies completely inside the polygon. Is there an algorithm to do that in O(N) time or better? Is there an algorithm that can find all visible vertices in O(N) time? A quick research suggests that

Suggestions on speeding up edge selection

戏子无情 提交于 2019-12-06 01:41:47
问题 I am building a graph editor in C# where the user can place nodes and then connect them with either a directed or undirected edge. When finished, an A* pathfinding algorithm determines the best path between two nodes. What I have: A Node class with an x, y, list of connected nodes and F, G and H scores. An Edge class with a Start, Finish and whether or not it is directed. A Graph class which contains a list of Nodes and Edges as well as the A* algorithm Right now when a user wants to select a

3d point closest to multiple lines in 3D space

為{幸葍}努か 提交于 2019-12-06 01:13:50
I search for non iterative, closed form, algorithm to find Least squares solution for point closest to the set of 3d lines. It is similar to 3d point triangulation (to minimize re-projections) but seems to be be simpler and faster? Lines can be described in any form, 2 points, point and unit direction or similar. Let the i th line be given by point a i and unit direction vector d i . We need to find the single point that minimizes the sum of squared point to line distances. This is where the gradient is the zero vector: Expanding the gradient, Algebra yields a canonical 3x3 linear system,

Minimize sum of distances in point pairs

回眸只為那壹抹淺笑 提交于 2019-12-06 00:06:09
问题 I have a bunch of points on a 2-dimensional Grid. I want to group the Points into pairs, while minimizing the sum of the euclidean distances between the points of the pairs. Example: Given the points: p1: (1,1) p2: (5,5) p3: (1,3) p4: (6,6) Best solution: pair1 = (p1,p3), distance = 2 pair2 = (p2,p4), distance = 1 Minimized total distance: 1+2 = 3 I suspect this problem might be solvable with a variant of the Hungarian Algorithm?! What is the fastest way to solve the problem? (Little Remark:

How do I find the overlapping area between two arbitrary polygons

与世无争的帅哥 提交于 2019-12-05 22:56:46
问题 I'm trying to create a method that will take in two arbitrary lists of nodes, for a subject and a clipping polygon, and output either: a) the area of the overlap b) a list of nodes for the resulting (clipped) polygon so that I can calculate the area I've found lots of examples which clip an arbitrary polygon using a rectangular window (which is fairly standard in graphics) but that's not what I need. I understand that it's fairly complex, particularly when you get holes, convex polygons and

How to search in a Range Tree?

半城伤御伤魂 提交于 2019-12-05 21:04:54
I read several slides, like this one 's last page, where the describe the search algorithm. However, I have a basic question. The data lie in a 2D space. I first build a Binary Search Tree based on the x value of the points. Every inner node holds a BST based on the y value of the points that lie in the subtree of that inner node. Then I think I should search for the points that lie in the range query [x1, x2] and then check if for that points the requested [y1, y2] range query is satisfied. However, the algorithm suggests that you should search in the y-based BST of an inner node, if the

Finding intersection between straight line and contour

☆樱花仙子☆ 提交于 2019-12-05 18:24:46
I am trying to find the intersection point of a straight(dashed red) with the contour-line highlighted in red(see plot). I used .get_paths in the second plot to isolate said contour line form the others(second plot). I have looked at a contour intersection problem, How to find all the intersection points between two contour-set in an efficient way , and have tried to use it as a base but have not been able to reproduce anything useful. http://postimg.org/image/hz01fouvn/ http://postimg.org/image/m6utofwb7/ Does any one have any ideas? relevant functions to recreate plot, #for contour def p_0

How to print the faces of a Voronoi diagram?

只谈情不闲聊 提交于 2019-12-05 16:13:34
Code bellow assumes input is points, not line segments (which is wrong). Following this 2D Voronoi Diagram Adaptor example, I am trying to write a program which takes as input line segments and prints the vertices of the faces of the Voronoi diagram. Here is my attempt (keeping includes/typedefs of the example): // standard includes #include <iostream> #include <fstream> #include <cassert> // includes for defining the Voronoi diagram adaptor #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Delaunay_triangulation_2.h> #include <CGAL/Voronoi_diagram_2.h> #include