computational-geometry

Approximating a polygon with a circle

核能气质少年 提交于 2019-12-10 03:32:03
问题 Well, approximating a circle with a polygon and Pythagoras' story may be well known. But what about the other way around? I have some polygons, that should be in fact circles. However, due to measurement errors they are not. So, what I'm looking for is the circle that best "approximates" the given polygon. In the following figure we can see two different examples. My first Ansatz was to find the maximum distance of the points to the center as well as the minimum. The circle we are looking for

Algorithm for fitting abstract distances in 2D

◇◆丶佛笑我妖孽 提交于 2019-12-10 01:54:58
问题 Suppose we are given a small number of objects and "distances" between them -- what algorithm exists for fitting these objects to points in two-dimensional space in a way that approximates these distances? The difficulty here is that the "distance" is not distance in Euclidean space -- this is why we can only fit/approximate. (for those interested in what the notion of distance is precisely, it is the symmetric distance metric on the power set of a (finite) set). 回答1: Given that the number of

Compute the size of Voronoi regions from Delaunay triangulation?

大城市里の小女人 提交于 2019-12-09 18:47:25
问题 I would like to compute the mean and standard deviation of the areas of a set of Voronoi regions in 2D (if the region extends to infinity, I'll just clip it to the unit square). However if possible I would like to do this computation from the Delaunay Triangulation without explicitly computing the Voronoi regions? Is this even possible, or is it better to just compute the Voronoi diagram explicitly? 回答1: In order to calculate the voronoi region of a vertex you need to iterate the 1-ring

segment-polygon intersection

孤人 提交于 2019-12-09 17:19:22
问题 Greetings, I would like to detect if a segment only 'touches' a polygon or cross it. The Figure explains my doubt. How to know the difference between cases A and B? Note that in both situations the red line crosses the polygons in two vertices, one touching by outside and other crossing by inside. I have a segment-segment intersection algorithm, but I don't know how to use it properly. Any help is appreciated. 回答1: I think there might not be any approach much easier than computing the details

Python : Ramer-Douglas-Peucker (RDP) algorithm with number of points instead of epsilon

可紊 提交于 2019-12-09 16:47:14
问题 I would like to modify this following python script for RDP algorithm with the purpose of not using epsilon but to choose the number of points I want to keep at the final : class DPAlgorithm(): def distance(self, a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def point_line_distance(self, point, start, end): if (start == end): return self.distance(point, start) else: n = abs( (end[0] - start[0]) * (start[1] - point[1]) - (start[0] - point[0]) * (end[1] - start[1]) ) d = sqrt(

line simplification algorithm: Visvalingam vs Douglas-Peucker

微笑、不失礼 提交于 2019-12-09 16:01:23
问题 I am trying to implement a line simplification algorithm . The main 2 algorithms I found are: Ramer-Douglas-Peucker Visvalingam-Whyat Currently I am running a few simulations of them on Matlab in order to determine which answers my needs better. The main goal for the algorithm is to simlipfy polygons in a map. My Input is a polygon\polyline and a threshold for mistake- epsilon. I need the simplified polygon to be as close as possible to the original, and I do not have a requirment for number

Is there an efficient way to count the number of intersections among a given set of line segments?

让人想犯罪 __ 提交于 2019-12-09 15:57:15
问题 Suppose I have n line segments in general position. How can I quickly count, for each of my n segments, how many of the other n-1 it intersects? I can do this naively in O(n 2 ) time. I can find all intersections using a fairly straightforward sweep line algorithm (Bentley-Ottmann) in O((n + k) log n) time, where k is the number of such intersections, and then aggregate the intersections I found into a bunch of counts. I don't need to find the intersections, though; I just want to know how

Given a vector of points (possibly out of order), find polygon (not convex hull)

亡梦爱人 提交于 2019-12-09 10:26:58
问题 I currently have a vector of points vector<Point> corners; where I have previously stored the corner points of a given polygon. Given that, I know for sure that the points form a simple polygon that does not contain any self-intersecting edges. However, in the process of storing these vertices, the order in which they connect to each other was not preserved. I now have a function that, given a vector of points, connects them and draws me a closed figure. However, I need to give this function

Finding if Path2D self-intersects

夙愿已清 提交于 2019-12-09 09:13:43
问题 I need to find if Path2D intersects itself. For now, I do it by simply extracting an array of lines from path, and finding if any of these intersect. But it has O(n^2) complexity, and so it is very slow. Is there a faster way to do it? 回答1: You can do this faster using the sweep-line algorithm: http://en.wikipedia.org/wiki/Sweep_line_algorithm Pseudocode: Each line has a start point and an end point. Say that `start_x` <= `end_x` for all the lines. Create an empty bucket of lines. Sort all

Determining and storing Voronoi Cell Adjacency

放肆的年华 提交于 2019-12-09 06:53:11
问题 I will be working with a set of thousands of points. I can implement or use existing implementations of Fortunes Algorithm to produce the Voronoi diagram of the points, but my application also requires me to know adjacency with respect to each Voronoi Cell. More specifically, for any Voronoi cell I need to know the cells that are adjacent to this. At this point I'm not to concerned with output or storage method as I can likely massage an implementation to work in my favor. Is anyone aware of