computational-geometry

Voronoi - Compute exact boundaries of every region

浪子不回头ぞ 提交于 2019-12-02 20:55:09
I'm trying to compute the exact boundaries of every region of a Voronoi Diagram using scipy.spatial.Voronoi, in the case when all the points are inside a pre-defined polygon. For example, using the example in the documentation, http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.spatial.Voronoi.html what if I need to compute Voroni with the same points but inside a rectangle with the following boundaries global_boundaries = np.array([[-2, -2], [4, -2], [4, 4], [-2, 4], [-2, -2]]) and I need to compute the precise boundaries of every voronoi region, like that? voronoi_region_1

Is point inside polygon?

送分小仙女□ 提交于 2019-12-02 20:15:57
问题 I need to write a function that will calculate if a point is inside polygon (true/false). Polygon always contains 4 points. I'm reading polygons and points from SVG file <g id="polygons"> <g id="LWPOLYLINE_183_"> <polyline class="st10" points="37.067,24.692 36.031,23.795 35.079,24.894 36.11,25.786 37.067,24.692 " /> </g> <g id="LWPOLYLINE_184_"> <polyline class="st10" points="35.729,23.8 35.413,23.516 34.625,24.39 34.945,24.67 35.729,23.8 " /> </g> <g id="LWPOLYLINE_185_"> <polyline class=

Given two (large) sets of points, how can I efficiently find pairs that are nearest to each other?

我是研究僧i 提交于 2019-12-02 19:24:25
I need to solve a computational problem that boils down to searching for reciprocally-nearest pairs of points between two sets. The problem goes something like this: Given a set of points A and a set of points B in euclidean space, find all pairs (a,b) such that b is the closest point in B to a and a is the closest point in A to b. The sets A and B are of approximately equal size, and we will call this size N. For my particular problem N is approximately 250,000. The brute force solution is to compare every point against every other point, which has quadratic time complexity. Is there any more

Asymptotically optimal algorithm to compute if a line intersects a convex polygon

人走茶凉 提交于 2019-12-02 19:09:22
An O(n) algorithm to detect if a line intersects a convex polygon consists in checking if any edge of the polygon intersects the line, and look if the number of intersections is odd or even. Is there an asymptotically faster algorithm, e.g. an O(log n) one? lhf's answer is close to correct. Here is a version that should fix the problem with his. Let the polygon have vertices v0, v1, ..., vn in counterclockwise order. Let the points x0 and x1 be on the line. Note two things: First, finding the intersection of two lines (and determining its existence) can be done in constant time. Second,

Triangle partitioning

﹥>﹥吖頭↗ 提交于 2019-12-02 18:38:24
This was a problem in the 2010 Pacific ACM-ICPC contest. The gist of it is trying to find a way to partition a set of points inside a triangle into three subtriangles such that each partition contains exactly a third of the points. Input: Coordinates of a bounding triangle: (v1x,v1y),(v2x,v2y),(v3x,v3y) A number 3n < 30000 representing the number of points lying inside the triangle Coordinates of the 3n points: (x_i,y_i) for i=1...3n Output: A point (sx,sy) that splits the triangle into 3 subtriangles such that each subtriangle contains exactly n points. The way the splitting point splits the

Algorithm or software for slicing a mesh

ぐ巨炮叔叔 提交于 2019-12-02 18:25:07
What is the right approach for slicing a 3D mesh? The mesh are all closed surfaces and the slices need to be binary images of what's inside the mesh. So for example, a mesh representing a sphere and slice images are those of filled circles. I am looking for a software library or algorithm that I can integrate into my current C++ project. My open source game library contains an implementation of mesh slicing. It works with the Irrlicht api, but could be rewritten to use a different API with a modest effort. You can use the code under the terms of the BSD license, or learn from it an implement

Determine non-convex hull of collection of line segments

徘徊边缘 提交于 2019-12-02 17:39:55
I have a computational geometry problem that I feel should have a relatively simple solution, but I can't quite figure it out. I need to determine the non-convex outline of a region defined by several line segments. I'm aware of various non-convex hull algorithms (e.g. alpha shapes), but I don't need a fully general algorithm, as the line segments define a unique solution in most cases. As @Jean-FrançoisCorbett has pointed out, there are cases where there are multiple solutions. I clearly need to think more about my definition. However, what I'm trying to do is reverse-engineer and use a

How to produce an ordered sequence of vertices of polygon from a discretized cellular representation of polygon

若如初见. 提交于 2019-12-02 17:00:40
问题 Here is the cellular representation of polygon shown:- Here is the extracted polygon shown. We are given the input as a matrix polM that stores 1 for pink cells and 2 for yellow cells. From the yellow colored cells we want to create a polygon. This is also done using below code derived from here. clear; close all; A=ones(25,25); indices=[64,65,88,89,90,91,111,112,113,114,115,116,117,135,136,137,138,139,140,141,142,143,158,159,160,161,162,163,164,165,166,167,168,169,182,183,184,185,186,187,188

2D Geometry library: LGPL alternative to CGAL? [closed]

折月煮酒 提交于 2019-12-02 16:37:10
CGAL seems to do just about everything I need and a little more for my upcoming project. It can create polygons out of arc line segments and run boolean operations on them. It has spatial sorting packages already that would save me a lot of time regarding a few things and the whole library seems quite standardized and well planned. There's just the issue with the license being QPL (GPL for the upcoming version 4.0) for most of the packages (except the very basic ones). I've got a meager budget and can likely not gather funds to buy the commercial licenses for those specific packages in CGAL

Choose the closest k points from given n points

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 15:16:42
You are given a set U of n points on the plane and you can compute distance between any pair of points in constant time. Choose a subset of U called C such that C has exactly k points in it and the distance between the farthest 2 points in C is as small as possible for given k. 1 < k <= n What's the fastest way to do this besides the obvious n-choose-k solution? A solution is shown in Finding k points with minimum diameter and related problems - Aggarwal, 1991. The algorithm described therein has running time: O(k^2.5 n log k + n log n) For those who have no access to the paper: the problem is