turns 0.1.1

Fixed-point angles modulo 2π backed by unsigned integers.
Documentation
  • Coverage
  • 100%
    73 out of 73 items documented1 out of 19 items with examples
  • Size
  • Source code size: 30.62 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 57s Average build duration of successful builds.
  • all releases: 47s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jpopesculian/turns
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jpopesculian

turns

CI crates.io docs.rs

Fixed-point angles modulo 2π, backed by unsigned integers.

Angle<T> represents an angle as an unsigned integer where the full range of T maps onto one full turn (2π radians / 360 degrees). Natural integer overflow provides wraparound at 2π, so modular arithmetic is free.

Type aliases Angle8, Angle16, Angle32, Angle64, and Angle128 cover the standard widths.

Usage

[dependencies]
turns = "0.1"
use turns::Angle8;
use core::f64::consts::PI;

let pi = Angle8::from_radians(PI);
assert_eq!(pi + pi, Angle8::from_radians(0.0_f64));

Features

  • std (default) — enables num-traits/std.
  • libm — enables num-traits/libm for transcendentals in no_std builds.

For no_std:

[dependencies]
turns = { version = "0.1", default-features = false, features = ["libm"] }

Precision

Float conversions are generic over any F: Float. Expect precision loss when the integer width exceeds the float mantissa (e.g. Angle128 with f64 keeps ~53 of 128 bits). Non-finite inputs (NaN, infinities) are coerced to zero rather than panicking.

License

MIT