intersect2d
After watching Philipp Kindermann's excellent sweep-line videos I think I finally understand how this algorithm works.
This is my humble take on an implementation of the segment line
intersection sweep-line algorithm.
The library crate also contains a line intersection function.
Code still in development, not ready for any purpose.
Interactive step-by-step example:
cargo run --example fltk_gui --features console_trace
Most of this crate have been adapted for nalgebra,
cgmath, mint and plain vector here.
This crate will remain geo based.
Intersection function API example:
use ;
use geo;
let line1: = .into;
let line2: = .into;
let _rv = intersect;
match _rv
// you can also get a single intersection point from the Intersection enum.
// Albeit geometrically incorrect, it makes things easy
if let Some =_rv
Sweep-line API example:
use geo;
use AlgorithmData;
let _l = vec!;
let results = default
.with_ignore_end_point_intersections?
.with_lines?
.compute?;
for in results.iter
Detection of self-intersecting geo::LineString:
let coords = vec!;
let line_string: LineString = coords.into_iter.collect;
// Obviously this example only makes sense for LinesStrings with many points.
// A simple brute force O(n²) intersection test will be faster than this O(log(n)n)
// sweep-line algorithm if n is small enough.
let result = default
.with_ignore_end_point_intersections?
.with_stop_at_first_intersection?
.with_lines?
.compute?;
for in result.iter
Todo
- Error handling
- Benchmark and optimize
- Stable overlapping co-linear line detection