spatial6 1.0.0

Backend-agnostic 6D spatial vectors, transforms, and inertias for rigid-body dynamics
Documentation

spatial6

Backend-agnostic 6D spatial vectors, transforms, and inertias for rigid-body dynamics. Spatial coordinates store angular components before linear components.

[dependencies]
spatial6 = "1.0"

The crate provides MotionVector, ForceVector, SpatialTransform, and RigidBodyInertia.

Feature Backend
builtin (default) Fixed Rust arrays
nalgebra Native nalgebra vectors and matrices
glam Native glam vectors and matrices
serde Serialize/Deserialize for all public types
No default features User-defined SpatialRepresentation

Enable optional backends with features = ["nalgebra"] or features = ["glam"]. Enable features = ["serde"] for serialization support; combined with nalgebra or glam, it also enables that backend's own serde integration so the underlying vector/matrix types serialize too.

See the API documentation for usage and conventions, and examples/ for worked algorithms built on these types: composite rigid-body inertia, inverse dynamics via the Recursive Newton-Euler Algorithm, and articulated-body inertia. Each of these three algorithms, plus a minimal single-rigid-body case, is worked through all three backends in a _nalgebra/_glam-suffixed sibling file (_builtin/no suffix is the default), so switching backends can be seen changing only the storage type, never the answer:

cargo run --example backend_builtin --no-default-features --features builtin
cargo run --example backend_nalgebra --no-default-features --features nalgebra
cargo run --example backend_glam --no-default-features --features glam

cargo run --example rnea_builtin --no-default-features --features builtin
cargo run --example rnea_nalgebra --no-default-features --features nalgebra
cargo run --example rnea_glam --no-default-features --features glam

cargo run --example composite_rigid_body_builtin --no-default-features --features builtin
cargo run --example composite_rigid_body_nalgebra --no-default-features --features nalgebra
cargo run --example composite_rigid_body_glam --no-default-features --features glam

cargo run --example articulated_inertia_builtin --no-default-features --features builtin
cargo run --example articulated_inertia_nalgebra --no-default-features --features nalgebra
cargo run --example articulated_inertia_glam --no-default-features --features glam

Contributing

Install Rust (stable, including rustfmt and Clippy) and uv, then run:

uv tool install pre-commit==4.6.2
pre-commit install
pre-commit run --all-files

Before submitting a change, run the same checks CI runs (which treats rustdoc warnings as errors):

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo test --no-default-features
cargo test --no-default-features --features nalgebra
cargo test --no-default-features --features glam
cargo test --features serde
cargo test --all-features
cargo doc --no-deps --all-features

License

Copyright 2026 Daisuke Nagao.

Licensed under either the MIT License or the Apache License, Version 2.0, at your option (MIT OR Apache-2.0). Copyright and SPDX license information is recorded in Rust file headers.