Closest pair of points across a line
I have two sets of 2D points, separated from each other by a line in the plane. I'd like to efficiently find the pair of points, consisting of one point from each set, with the minimum distance between them. There's a really convenient looking paper by Radu Litiu, Closest Pair for Two Separated Sets of Points, but it uses an L1 (Manhattan) distance metric instead of Euclidean distance.
Does anyone know of a similar algorithm which works with Euclidean distance?
I can just about see an extension of the standard divide & conquer closest pair algorithm -- divide the two sets by a median line perpendicular to the original splitting line, recurse on the two sides, then look for a closer pair consisting of one point from each side of the median. If the minimal distance from the recursive step is d, then the companion for a point on one side of the median must lie within a box of dimensions 2d*d. But unlike with the original algorithm, I can't see any way to bound the number of points within that box, so the algorithm as a whole just becomes O(m*n).
Any ideas?
Similar Questions
so I'm just starting to learn how to create live wallpapers in eclipse and I'm having trouble getting a simple line to move randomly across the screen after a random amount of time, sort of like a sho
I try to write the closest pair in n dimension, I use the divide and conquer.And I first split it into left and right part, and find their shortest path respectively and I have to find the distance ac
I have some damaged line segments in a binary image and I need to fix them (make them straight and at their original thick). In order to do that I have to find the middle points of the segment, so whe
I have a number of points on a 2D graph, and I am concerned with they quadrant they lie in than the actual coordinates itself. I have a function ReflectX() which performs Reflecting along X-axis on
I use exlipse kepler with m2e. When debugging a maven project with the debugger, it shows me the false line numbers in the debugger. It starts at the javadoc and does not enter into the function body.
I need to paint the line which links two points. I am doing it, in Java. I receive two points as parameters and I have to calculate if the straight line between them, is inside the black figure. I de
I'm trying to get the closest data from the following data > db.points.insert({name:Skoda , pos : { lon : 30, lat : 30 } }) > db.points.insert({name:Honda , pos : { lon : -10, lat : -20 } })
Closest distance between two points(disjoint set) In the Bichromatic Closest Pair Problem, we are given a set R of red points and a set B of blue points in the plane. The problem is to return the pair
In the grid constructed by grid points (M*x, M*y) and given the point A(x1,y1) and point B(x2,y2) where all the variables are integers. I need to check how many grid points lie on the line segment fro
I'm looking for a way to make a line curve through a number of points. It would be preferable to use 3 points although I've considered that in order to give context to the angle of the line entering a
I have a text file that has a bunch of key value pairs. The key value pairs are not in the same order in each line, and only my sequence key is guaranteed to be in each line. How can I sort the file i
I am drawing svg line using D3.js. I want to improve performance by removing duplicate (x,y) points before adding to line path. What is the best way to do this in D3 or javascript. I am loading data f
I'm trying to draw a line between two (2D) points when the user swipes their finger across a touch screen. To do this, I plan on drawing a rectangle on every touch update between the X and Y of the pr
New to Python. Trying to analyze the algorithm for Closest pair of points. Found an example Which has these lines: return min( ((abs(point[i] - point[j]), (point[i], point[j])) for i in range(numPoin
How can i draw a line between two particular longitude and latitude points in android? In my application i want to draw shortest distance path between two points which is given in the database.
I am using Point Cloud Library. I know there is a function to find lines using RANSAC method, but I want to do opposite of that. I have a point cloud, I have an equation of line, now, I would like to
Given a set of points, I am trying to select a subset of n points that are most evenly distributed across this set of points. In other words, I am trying to thin out the dataset while still evenly sam
Assume that we have been given a set S of n points and an arbitrary query line l. Do some preprocessing (other than duality) so that we can answer the nearest (closest) point (of S) to l in O(log n) t
I try to get the 10 closest Markers from the center of the google map and sort them based of the center by distance in Javascript. So lets say i have 100 Markers in a Javascript array - i would like t
It is obviously possible to hide individual data points in an Excel line chart. Select a data point. Right click -> Format Data Point... Select Patterns Tab Set Line to None How do you accompli
Hello friends…. I am trying to find the angle of outer line of the object in the green region of the image as shown in above image… For that I have scanned the green region and get the points (dark bl
There is a function in google maps geometry library interpolate(from:LatLng, to:LatLng, fraction:number) which finds a point between two other points: A--X--B I need something very similar, find a
I'm working on a graphical program and I'd like to get corner points from figures I mentioned in the title. I need them because at those points places, I want to place white, little rectangles that al
I have a small question regarding the ggplot, where in I want to know how to get the data points start with a 0 line without leaving that small gap on the left, right and the bottom. This is my code:
Consider some points on a 2d plane and function f(x)=ax, where b=0. Let's say a point is a 1x1 square. Now we want to tell how many points is between f(x) function and y line, as in picture below. Bl
My Question is how can I select the .closest('table') of the .closest('table'). I tried: $('div').closest('table').closest('table').hide(); and it didn't work, is there a way to select the closest ta
in order to get a homography between two images, I wanted to know how many points I need at least to get a good estimation of the homography matrix?
I have been trying to figure this out for sometime now.. The problem to solve.. Say I have 3 Points.. P1 ---------- P2, and P3 can be anywhere around P1 and P2 What is the formula to calculate so th
Is it possible to add a new and remove data points on a kendoUI line chart without refreshing the chart? Data will be coming in every 5 seconds and can go upto a maximum of 720 data points on the char
I'm creating a Chart with Lines on it in VB.NET. Now I got multiple Values in one Line. I want to mark certain of these values with a little Circle (or a Sqare, nevermind). How do I have to do this? I
So we have a reference set of 3D points (let's call it R), and many other sets of 3D points (let's call that set of sets of data points P, and each data set in that Pi). The task is to return the Pi t
I am trying to find out if a line defined by two points is greater than or equal to 90 degrees compared to the horizontal. Here is the code I used bool moreThan90 = false; double angle = Math.Atan((do
If I draw a line from let's say: (2,3) to (42,28), how can I get all points on the line in a Point list? I tried using the slope, but I can't seem to get the hang of it. To be clear: I would like all
It is known that the intersection points between a line and a polyline can be found using Polyxpoly command in MATLAB. However, the examples given here involve the polylines that are composed of point
I found a Google Interview question on CareerCup Given a 2D plane, suppose that there are around 6000 points on it. Find a line which passes the most number of points. Many answers there say this qu
Assume that we have 1 billion points in 3 dimensional space (or 2d, it doesn't matter at the moment), we want to find k closest points (a subset of points with size k that are closer to each other tha
I have line chart which has values : flock_age = X-axis = 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 egg_mass_weekly Y-axis = 0.00, 0.00, 0.00, 0.00, 0
I am writing a method that takes as input an array of points and finds, for each point in the array, the closest point to it other than itself. I am currently doing this in a brute force way (cheking
Highcharts box plots have a fantastic feature that offsets box plots when 2 series' are on the same point of the x axis. My problem is that I also have a trend line along the median that is linked to
How would I go about drawing a UIBezierpath to connect three points. I know that there must be a formula/algorithm, but I've been searching and can not find it. Would somebody be able to help me with
Ok, so I have two files which contain identical text with the exception of one line, what I'm doing is copying the differing line from the %source% file to the %target% file (which in essence is just
Currently, the below code (part of a more comprehensive code) generates a line that ranges from the very left to the very right of the graph. geom_abline(intercept=-8.3, slope=1/1.415, col = black,
Hi I am writing an application with java. In my application I need a method to connect each point to its two closest point between many different points (draw a line from a point to its two closest po
I've been trying to wrap my head around this the whole day... Basically, I have the coordinates of two points that will always be inside a rectangle. I also know the position of the corners of the rec
I'm using Mapsforge and I've got a MapView I've added some points to. Some of the points are too close for the user to be able to click them and get the right popup, even zoomed in all the way. What I
I have 2 layers. A lines layer and a points layer. For any given line, how can I find the points that intersect the envelope of the line, but not the line itself, or more specifically, not the to poin
// F# Brute force: let closest_pairs (xys: Point []) = let n = xys.Length seq { for i in 0..n-2 do for j in i+1..n-1 do yield xys.[i], xys.[j] } |> Seq.minBy (fun (p0, p1) -> (p1 - p0).LengthSqu
I would like to plot a line that connects the outer points of the plot plot(rnorm(1000), rnorm(1000), xlim=c(-5,5),ylim=c(-5,5)) and thus bags all points of the plot
I have a custom shape as shown in image. Suppose the blue rectangle covering the shape in the image depicts the bounding box of that shape. If I draw line at one of the diagonal of the bounding recta
As my cursor moves, I grab the two closest points IF it is not already on a plotted point. I want to be able to make these two closest points light up (i.e. change colour to something orange or somet