Expand description
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.
§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.
§Example
use turns::Angle8;
use core::f64::consts::PI;
let pi = Angle8::from_radians(PI);
assert_eq!(pi + pi, Angle8::from_radians(0.0_f64));Structs§
- Angle
- Fixed-point angle modulo 2π, stored as an unsigned integer
T.
Type Aliases§
- Angle8
- 8-bit angle: one full turn per 256 steps.
- Angle16
- 16-bit angle: one full turn per 65,536 steps.
- Angle32
- 32-bit angle: one full turn per 2³² steps.
- Angle64
- 64-bit angle: one full turn per 2⁶⁴ steps.
- Angle128
- 128-bit angle: one full turn per 2¹²⁸ steps.
- Angle
Size - Pointer-width angle: one full turn per
usize::MAX + 1steps (platform-dependent).