Line library for Rust (Work in progress)
This crate contains data structures and methods that deals with lines in 2D and 3D space.
There are 3D and 2D implementations of:
- LineString, a sequence of points, aka Polyline.
- Self intersection tests for lines in 2d, O( n log n + i log n).
- Line, a finite two-point struct (no rays).
- Ramer–Douglas-Peucker and
- Visvalingam-Whyatt line simplification algorithms.
- Aabb axis aligned bounding box.
- sampling of boostvoronoi parabolic arc curves.
This is implemented for cgmath,
nalgebra, vecmath
and limited versions for mint and plain vectors (no transformations etc).
These implementations are feature gated, so you only have to include the 3d package you need in your code.
More implementations could be added if required.
If you want to use this library in your cgmath project you add this to your Cargo.toml:
linestring = {version="^0.0.12",default-features=false,features=["impl-cgmath"]}
Same thing for the other supported 2d/3d libraries:
linestring = {version="^0.0.12",default-features=false,features=["impl-nalgebra"]}
linestring = {version="^0.0.12",default-features=false,features=["impl-mint"]}
linestring = {version="^0.0.12",default-features=false,features=["impl-vecmath"]}
linestring = {version="^0.0.12",default-features=false,features=["impl-vec"]}
The difference between impl-vecmath
and impl-vec
is that the impl-vecmath
feature supports
affine transformations.
Demo GUI
Run the line simplification example with :
cargo run --example fltk_gui --no-default-features --features impl-cgmath
Todo
- Improve on error handling
- Benchmark and optimize (add smallvec to simplify rdp?)
- optimize Ramer–Douglas-Peucker
- optimize Visvalingam-Whyatt
- figure out how to deal with rustdoc (the feature gates disables it).
- Add 2D Convex hull and containment tests
- Stable overlapping co-linear line detection
- Better event handling in fltk_gui