2 unstable releases
Uses new Rust 2024
| 0.1.0 | Aug 20, 2025 |
|---|---|
| 0.0.0-reserved | Aug 8, 2025 |
#2780 in Algorithms
67 downloads per month
33KB
920 lines
Angles (degrees, radians, and turns).
Why
This crate provides a type-safe abstraction for working with angles in different units (radians, degrees, turns, and percentage of a full circle). It helps prevent mistakes when converting between units and provides a convenient API for common angle operations.
Angle is currently represented as f32-based radians, but may be extended in the future.
Examples
use askew::Angle;
let angle = Angle::from_degrees(90.0);
assert_eq!(angle.as_radians(), std::f32::consts::PI / 2.0);
assert_eq!(angle.as_degrees(), 90.0);
assert_eq!(angle.as_turns(), 0.25);
assert_eq!(angle.as_percentage(), 0.25);
Features
This crate is #![no_std] compatible, but by default uses std for floating-point operations.
approx
Enables the approx crate for implementing traits like RelativeEq.
bytemuck
Enables the bytemuck crate for zero-copy conversions.
libm
Enables the libm crate for floating-point operations.
serde
Enables the serde crate for serialization and deserialization.
std
Enables the standard library for floating-point operations.
If you want to use the libm crate instead, disable this feature:
[dependencies.askew]
default-features = false
features = ["libm"]
askew
Angles (degrees, radians, and turns).
Contributing
This project uses just to run commands the same way as the CI:
cargo just checkto check formatting and lints.cargo just coverageto generate and preview code coverage.cargo just docto generate and preview docs.cargo just testto run tests.
For a full list of commands, see the Justfile.
Dependencies
~0–360KB