computational-geometry

What is the fastest way to find the closest point to a given point?

泄露秘密 提交于 2019-11-26 09:27:08
问题 What is the fastest way to find closest point to the given point in data array? For example, suppose I have an array A of 3D points (with coordinates x, y and z, as usual) and point (x_p, y_p, z_p). How do I find the closest point in A to (x_p, y_p, z_p)? As far as I know, slowest way to do it is to use linear search. Are there any better solutions? Addition of any an auxiliary data structure is possible. 回答1: You may organize your points in an Octree. Then you only need to search a small

Angle between two vectors in R

帅比萌擦擦* 提交于 2019-11-26 09:26:25
问题 What the most efficient way in the programming language R to calculate the angle between two vectors? 回答1: if you install/upload the library(matlib): there is a function called angle(x, y, degree = TRUE) where x and y are vectors. Note: if you have x and y in matrix form, use as.vector(x) and as.vector(y): library(matlib) matA <- matrix(c(3, 1), nrow = 2) ##column vectors matB <- matrix(c(5, 5), nrow = 2) angle(as.vector(matA), as.vector(matB)) ##default in degrees, use degree = FALSE for

robust algorithm for surface reconstruction from 3D point cloud?

喜欢而已 提交于 2019-11-26 08:57:44
问题 I am trying to figure out what algorithms there are to do surface reconstruction from 3D range data. At a first glance, it seems that the Ball pivoting algorithm ( BPA ) and Poisson surface reconstruction are the more established methods? What are the established, more robust algorithm in the field other than BPA and Poisson surface reconstruction algorithm? Recommended research publications? Is there available source code? 回答1: I have been facing this dilemma for some months now, and made

Geo Fencing - point inside/outside polygon

倾然丶 夕夏残阳落幕 提交于 2019-11-26 08:47:20
问题 I would like to determine a polygon and implement an algorithm which would check if a point is inside or outside the polygon. Does anyone know if there is any example available of any similar algorithm? 回答1: Just have a look at the point-in-polygon (PIP) problem. 回答2: If i remember correctly, the algorithm is to draw a horizontal line through your test point. Count how many lines of of the polygon you intersect to reach your point. If the answer is odd, you're inside. If the answer is even,

How do I detect intersections between a circle and any other circle in the same plane?

扶醉桌前 提交于 2019-11-26 08:05:09
问题 I\'m looking for an algorithm to detect if a circle intersects with any other circle in the same plane (given that there can be more than one circle in a plane). One method I have found is to do the separating axis test. It says: Two objects don\'t intersect if you can find a line that separates the two objects, i.e. a line such that all objects or points of an object are on different sides of the line. However, I don\'t know how to apply this method to my case. Can anybody help me? 回答1: Two

How to Compute OBB of Multiple Curves?

半城伤御伤魂 提交于 2019-11-26 07:49:57
问题 Given a number of curves,include line segments and circular arcs, how to compute the total OBB of all curves? It seems that the union of each OBB of the individual curves does not right, it\'s not the minimal coverage. Check this picture, how to compute the red box? 回答1: you should also add the input in vector form so we can test on your data ... I would approach like this: find center of axis aligned bbox O(n) compute max distance in each angle O(n) just create table for enough m angles

draw outline for some connected lines

早过忘川 提交于 2019-11-26 07:49:21
问题 I have some lines that are connected at various points. I want to draw the outline of these lines and I also want to deal with the extra lines at the connection points. I have seen two similar questions in this website: Here and here I have handled the normal cases by offsetting the Centerlines and then changing the start and end points of the lines. but I haven\'t been able to deal with special cases when the points are near each other. Unfortunately, my reputation is low I couldn\'t post

Catmull-Rom interpolation on SVG Paths

本小妞迷上赌 提交于 2019-11-26 07:42:18
问题 I am experimenting with creating high-performance, good-looking pencil tools using SVG paths. I am logging the mouse coordinates to draw a path. To get a high-fidelity path (accurate to the user\'s movements) I need to log a point for every pixel movement. Keeping each and every point in the path creates a huge amount of points which is not ideal for collaborative features later-on (sending huge amount of points back and forth is not efficient), plus parsing huge paths every time I need to

Largest circle inside a non-convex polygon

风格不统一 提交于 2019-11-26 07:23:14
问题 How can I find the largest circle that can fit inside a concave polygon? A brute force algorithm is OK as long as it can handle polygons with ~50 vertices in real-time. 回答1: The key to solving this problem is first making an observation: the center of the largest circle that will fit inside an arbitrary polygon is the point that is: Inside the polygon; and Furthest from any point on the edges of the polygon. Why? Because every point on the edge of a circle is equidistant from that center. By

Implementing Hoey Shamos algorithm with C#

情到浓时终转凉″ 提交于 2019-11-26 06:46:26
问题 Okay, I am now getting the correct information from my current algorithm! However, with 700,000 polygons to check, it\'s just way too slow! The previous issue is fixed (My Line2D intersectsWith method was incorrect) Now it\'s a matter of identifying my bottleneck! This algorithm is suppose to be O(nlog-n) so it should be much quicker. My intersectsWith method looks like it can\'t get any faster, however I will post its code, in case I\'m wrong EDIT: Added IComparable interface My method for