Implementing Hoey Shamos algorithm with C#

First, regarding the line intersection: you do not need the actual point of intersection, only to know if they intersect. See http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/ for an algorithm that does just that. About the List implementation: In your implementation using Lists, you call indexOf on the sweepline to find nl. This searches the sweepline from start to end. … Read more

How to check if line segment intersects a rectangle?

One very simple option would be to use a standard algorithm for checking whether two line segments intersect to check whether the line segments intersects any of the four line segments that make up the corners of the box. It’s computationally very efficient to check if two line segments intersect, so I would expect that … Read more

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line

BTW complexity is indeed O(n^3) to lower that you need to: sort the points somehow by x and or y in ascending or descending order. Also use of polar coordinates can help sometimes use divide at impera (divide and conquer) algorithms usually for planar geometry algorithms is good idea to divide area to quadrants and … Read more

What is the fastest algorithm to calculate the minimum distance between two sets of points?

Perhaps you should check out (PDF warning! Also note that, for some reason, the order of the pages is reversed) “Optimal Algorithms for Computing the Minimum Distance Between Two Finite Planar Sets” by Toussaint and Bhattacharya: It is shown in this paper that the minimum distance between two finite planar sets if [sic] n points … Read more

tech