computational-geometry

Implementing the Bentley-Ottmann algorithm

江枫思渺然 提交于 2019-12-09 06:40:00
问题 I am having some trouble correctly implementing the Bentley-Ottmann algorithm in C#. I am trying to implement it according to the pseudocode here. I have posted my main code below. Assuming my BST and PriorityQueue classes are implemented correctly, do you see any problems with the code? There are no errors, but not all intersection points are found, only some. My guess is that there's an error in the else part of the code (when the current event is an intersection point). I'm not sure what

Algorithm to find intersections between polylines

一曲冷凌霜 提交于 2019-12-09 06:15:41
问题 Bentley-Ottmann algorithm works for finding intersections of set of straight lines. But I have lot of polylines: Is there a way to find intersections of the set of polylines? I'm figuring out, but in the meanwhile, if someone can give some pointers or ideas, that would be helpful. Thanks for reading. By the way, I'm using WPF/C# and all the polylines are PathGeometry. Source of the Image: http://www.sitepen.com/blog/wp-content/uploads/2007/07/gfx-curve-1.png 回答1: The sweep line algorithm has

Convex hull in higher dimensions, finding the vertices of a polytope

非 Y 不嫁゛ 提交于 2019-12-09 05:39:23
问题 Suppose I have a point cloud given in 6-dimensional space, which I can make as dense as needed. These points turn out to lie on the surface of a lower-dimensional polytope (i.e. the point vectors (x1, x2, ... x6) appear to be coplanar). I would like to find the vertices of this unknown polytope and my current attempt makes use of the qhull algorithm, via the scipy interface in Python. In the beginning I would only get error messages, apparently caused by the lower dimensional input and/or the

Compute the area covered by cards randomly put on a table

扶醉桌前 提交于 2019-12-09 05:11:15
问题 This is an interview question, the interview has been done. Given a deck of rectangular cards, put them randomly on a rectangular table whose size is much larger than the total sum of cards' size. Some cards may overlap with each other randomly. Design an algorithm that can calculate the area the table covered by all cards and also analyze the time complexity of the algorithm. All coordinates of each vertex of all cards are known. The cards can overlap in any patterns. My idea: Sort the cards

clipping a voronoi diagram python

百般思念 提交于 2019-12-09 04:59:21
问题 I am computing a voronoi diagram from a set of points as follows: from scipy.spatial import Voronoi import numpy as np np.random.seed(0) points = np.random.uniform(-0.5, 0.5, (100, 2)) // Compute Voronoi v = Voronoi(points) voronoi_plot_2d(v) plt.show() This creates an image as follows: As one can see, this is creating vertices which are going to infinity (dashed lines) and also beyond the original bounding box for the points which is: bbox = np.array([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [

How to find first intersection of a ray with moving circles

跟風遠走 提交于 2019-12-09 04:53:30
问题 I have been struggling with a problem for a while and so far have not found any solution better then the naive one: N circles are given that are moving according to a linear law. For each of the circles we have its initial (at moment 0.0) radius, initial coordinates and its radius and coordinates at moment 1.0 (end moment). We also have k rays given with coordinates of their origin and a vector along the ray. Each ray only exists at a given moment t k . I need to be able to find the first

How to find all the intersection points between two contour-set in an efficient way

我的梦境 提交于 2019-12-09 04:25:09
问题 I'm wondering about the best way to find all the intersection points (to roundoff error) between two sets of contour lines. Wich is the best method? Here is the example: import matplotlib.pyplot as plt import numpy as np x = np.linspace(-1,1,500) X,Y = np.meshgrid(x,x) Z1 = np.abs(np.sin(2*X**2+Y)) Z2 = np.abs(np.cos(2*Y**2+X**2)) plt.contour(Z1,colors='k') plt.contour(Z2,colors='r') plt.show() I want some similar to: intersection_points = intersect(contour1,contour2) print intersection

A programming challenge with Mathematica

随声附和 提交于 2019-12-08 20:59:27
I am interfacing an external program with Mathematica. I am creating an input file for the external program. Its about converting geometry data from a Mathematica generated graphics into a predefined format. Here is an example Geometry. Figure 1 The geometry can be described in many ways in Mathematica. One laborious way is the following. dat={{1.,-1.,0.},{0.,-1.,0.5},{0.,-1.,-0.5},{1.,-0.3333,0.},{0.,-0.3333,0.5}, {0.,-0.3333,-0.5},{1.,0.3333,0.},{0.,0.3333,0.5},{0.,0.3333,-0.5},{1.,1.,0.}, {0.,1.,0.5},{0.,1.,-0.5},{10.,-1.,0.},{10.,-0.3333,0.},{10.,0.3333,0.},{10.,1.,0.}}; Show

How to draw a circle in GNU Octave

跟風遠走 提交于 2019-12-08 15:40:41
问题 In Matlab you can draw a circle by just specifying the center and the radius like this: R = 10; Center = [5,8]; circle(Center,R,1000,'b-'); hold on plot(Center(1),Center(2),'g.') The same code for MatLab won't work for GNU Octave. What octave code would draw a circle given a center x,y coordinates and a radius? 回答1: t = linspace(0,2*pi,100)'; circsx = r.*cos(t) + x; circsy = r.*sin(t) + y; plot(circsx,circsy); 回答2: Using the octave extra package octave-geometry you can use the function

Geometry Arc Algorithm

北战南征 提交于 2019-12-08 11:44:51
问题 I searched all internet and didn't find any pseudo code that solved this problem, I want to find an Arc between two points, A and B, using 5 arguments: Start Point End Point Radius (Don't know if this is needed) Angle Quality Example: StartPoint = The green point on the left is the Start Point set on the arguments EndPoint = The green point on the right is the End Point set on the arguments Angle = Angle of the Arc(Semi Circle) Quality = How many red circles to create I would like to have a