linestring

Crates.iolinestring
lib.rslinestring
version0.13.0
sourcesrc
created_at2021-02-10 13:29:11.28737
updated_at2023-12-08 15:43:45.411425
descriptionline string toolbox
homepage
repositoryhttps://codeberg.org/eadf/linestring_rs
max_upload_size
id353222
size472,129
eadf (eadf)

documentation

README

crates.io Documentation status-badge dependency status license

Linestring: poly-lines for generic vectors.

linestring is a Rust crate providing data structures and methods for working with poly-lines and segments in 2D space. Utilizing the vector-traits crate, it abstracts over different vector implementations allowing for seamless transitions between vector libraries like glam and cgmath (for now).

Features

  • Generic Vector Support: Seamlessly switch between different vector implementations.
  • Simple API, most of the functionality is implemented for Vec<GenericVector2> and Vec<GenericVector3>
  • Core Data Structures: LineString, Line, and axis-aligned bounding box (Aabb).
  • Line Simplification Algorithms: Ramer–Douglas–Peucker and Visvalingam-Whyatt.
  • Curve Sampling: Sampling of boostvoronoi parabolic arc curves.
  • Convex Hull Calculation: Gift wrapping & Graham scan algorithms.
  • Intersection Tests: Self-intersection tests for line strings, or groups of lines with O( n log n + i log n) complexity.
  • Containment Test: Convex hull containment test.

Usage

Include the following dependencies in your Cargo.toml file, picking the vector implementation you need:

vector-traits = {version="0.3.2", features= ["glam","cgmath"]} # pick cgmath or glam, whatever you need
linestring = {version="0.12"}

Example

// the vector type can just as well be glam::Dvec2, cgmath::Vector2<f32> or cgmath::Vector2<f64>,
let some_points: Vec<glam::Vec2> = vec![
    vec2(77f32, 613.),
    vec2(689., 650.),
    vec2(710., 467.),
    vec2(220., 200.),
];
let convex_hull:Vec<glam::Vec2> = some_points.convex_hull()?;
for p in some_points {
    assert!(convex_hull.contains_point_inclusive(p));
}

Minimum Supported Rust Version (MSRV)

The minimum supported version of Rust for linestring is 1.66.

Contributing

We welcome contributions from the community. Feel free to submit pull requests or report issues on our GitHub repository. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

License

Licensed under either of

at your option.

Commit count: 0

cargo fmt