-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
24 lines (13 loc) · 801 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Implementation of the Bentley-Ottmann algorithm for 2d line segment intersection.
See:
de Berg et al., Ch. 2
http://en.wikipedia.org/wiki/Bentley-Ottmann_algorithm
for more information.
Usage:
from lsi import intersection
# S is a list of tuples of the form: ((x,y), (x,y))
i = intersection(S)
This function returns a dictionary of intersection points (keys) and a list of their associated segments (values).
Currently, this implementation does not handle horizontal/vertical line segments. This will be changed shortly!
A test file is available. It compares the running time of the algorithm to that of a brute-force O(N^2) comparison. It also generates a specified number of random input segments--you can set the precision and range by editing the file.
Email at: [email protected]