vector-traits 0.1.0

Rust traits for 2D and 3D vector types.
Documentation

crates.io Documentation Workflow dependency status license

Vector-Traits Crate

vector-traits is a Rust crate designed to provide a set of traits for abstracting over different vector implementations and scalar types, offering a unified interface for a basic set of vector operations. This crate facilitates seamless transitions between different vector libraries and scalar precisions (e.g., f32 and f64) without requiring significant code modifications.

Features

  • Abstract over two-dimensional and three-dimensional vectors with GenericVector2 and GenericVector3 traits.
  • Generic scalar trait GenericScalar for a flexible scalar type handling.
  • Basic vector traits HasXY and HasXYZ for custom vector storage types, e.g., FFI types.
  • Seamless transition between different vector libraries like cgmath and glam.
  • Ability to switch between different scalar types (f32, f64) effortlessly.
  • Optional approx feature for approximate equality checking through the SimpleApprox trait.

Supported Vector Implementations

Currently, the following vector types from cgmath and glam libraries are supported:

  • glam::Vec2
  • glam::DVec2
  • glam::Vec3
  • glam::DVec3
  • cgmath::Vector2
  • cgmath::Vector3

Usage

Add vector-traits to your Cargo.toml dependencies along with the desired features:

[dependencies]
vector-traits = { version = "0.1.0", features = ["glam", "cgmath", "approx"] }  # only use what you need

Documentation

For a deeper dive into vector-traits functionality, check the documentation generated by cargo doc or browse it online here.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

Licensed under either of

at your option.