Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 2.88 KB

report.org

File metadata and controls

43 lines (38 loc) · 2.88 KB

Project Report: Plane Sweep Line Intersection

All the code for this project is available at https://github.com/anirudh-c/plane-sweep

Implementation Details

I use an AVL tree implementation for representing the event and status lists for the plane sweep algorithm. The same base class BST can be used for both by just providing alternate priority functions that define how two points (events) or line segments (status list) can be ordered.

Also, the brute force and plane sweep algorithms are inherited from the same class _Algorithm which can be extended for any line segment intersection algorithm.

Comparing Brute-Force and Plane Sweep Algorithms

The program keeps track of every comparison made while computing the line intersection. In the brute force algorithm, every pair of line segments is compared. On the other hand for the plane sweep algorithm, at each event point $\mathcal{O}(1)$ line segments are compared, that is, only the neighbours of specific line segments. Obtaining these neighbours takes $\mathcal{O}(log{n})$ time.

To illustrate this, the program visualises each comparison performed in the algorithm via the GUI. I have provided a few instances of the visualisations of comparisons between line segments in the casts/ folder.

I time the executions of both algorithms for the given test cases. I run the algorithms 100 times for each test case file and average the running times. The corresponding script is time.sh and the test case files are in the tests/ folder.

Test# Line Segments# IntersectionsBrute ForcePlane Sweep
/<<<<<>
test-1870.65410.6416
test-2890.67080.656
test-316230.66220.6628
test-430200.68820.643
test-536400.671200.6698

There isn’t too much of an execution time difference (which I believe is to do with the AVL tree implementation using recursion, which is slower in python compared to loops).

The usage and details of the graphic interface are available at the repository link provided above and also in the README.