computational-geometry

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

三世轮回 提交于 2019-11-27 00:38:25
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. dkamins You may organize your points in an Octree . Then you only need to search a small subset. A Octree is a fairly simple data structure you can implement yourself (which would be a

polygon union without holes

北城余情 提交于 2019-11-27 00:37:58
问题 Im looking for some fairly easy (I know polygon union is NOT an easy operation but maybe someone could point me in the right direction with a relativly easy one) algorithm on merging two intersecting polygons. Polygons could be concave without holes and also output polygon should not have holes in it. Polygons are represented in counter-clockwise manner. What I mean is presented on a picture. As you can see even if there is a hole in union of polygons I dont need it in the output. Input

Algorithm to generate random 2D polygon

风流意气都作罢 提交于 2019-11-27 00:14:18
问题 I'm not sure how to approach this problem. I'm not sure how complex a task it is. My aim is to have an algorithm that generates any polygon. My only requirement is that the polygon is not complex (i.e. sides do not intersect). I'm using Matlab for doing the maths but anything abstract is welcome. Any aid/direction? EDIT: I was thinking more of code that could generate any polygon even things like this: 回答1: There's a neat way to do what you want by taking advantage of the MATLAB classes

Geo Fencing - point inside/outside polygon

我们两清 提交于 2019-11-26 23:47:29
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? Just have a look at the point-in-polygon (PIP) problem . Ian Boyd 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, you're outside. Edit: Yeah, what he said ( Wikipedia ): kober C# code bool IsPointInPolygon(List<Loc>

draw outline for some connected lines

感情迁移 提交于 2019-11-26 23:13:05
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 images to explain this better. I'm coding in Visual Basic .net and I'm writing for Autocad, but any advice

What is the algorithm for finding the center of a circle from three points?

旧街凉风 提交于 2019-11-26 22:41:38
问题 I have three points on the circumference of a circle: pt A = (A.x, A.y); pt B = (B.x, B.y); pt C = (C.x, C.y); How do I calculate the center of the circle? Implementing it in Processing (Java). I found the answer and implemented a working solution: pt circleCenter(pt A, pt B, pt C) { float yDelta_a = B.y - A.y; float xDelta_a = B.x - A.x; float yDelta_b = C.y - B.y; float xDelta_b = C.x - B.x; pt center = P(0,0); float aSlope = yDelta_a/xDelta_a; float bSlope = yDelta_b/xDelta_b; center.x =

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

社会主义新天地 提交于 2019-11-26 21:56:01
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? dasblinkenlight Two circles intersect if, and only if, the distance between their centers is between the sum and

For a point in an irregular polygon, what is the most efficient way to select the edge closest to the point?

做~自己de王妃 提交于 2019-11-26 21:27:14
问题 Given an irregular polygon and a point within that polygon, how do I determine which edge in the polygon is closest to the point? I will likely have to run this calculation for a large set of points within the polygon (e.g. 50-200 points). 回答1: Calculate closest point on the line that is tangent to each edge of the polygon. Calculate closest point on each line segment (edge of the polygon) to the point in question. Calculate the distance from the closest point on each line segment to the

Largest circle inside a non-convex polygon

别说谁变了你拦得住时间么 提交于 2019-11-26 19:42:38
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. cletus 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 definition, the largest circle will have the largest radius and will touch the polygon on at least

How to find convex hull in a 3 dimensional space

落爺英雄遲暮 提交于 2019-11-26 19:25:36
问题 Given a set of points S (x, y, z) . How to find the convex hull of those points ? I tried understanding the algorithm from here, but could not get much. It says: First project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this