2 unstable releases

Uses new Rust 2024

0.1.0 Aug 20, 2025
0.0.0-reserved Aug 8, 2025

#2780 in Algorithms

Download history

67 downloads per month

MIT license

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).

Test Docs Crates.io Version codecov

Contributing

This project uses just to run commands the same way as the CI:

  • cargo just check to check formatting and lints.
  • cargo just coverage to generate and preview code coverage.
  • cargo just doc to generate and preview docs.
  • cargo just test to run tests.

For a full list of commands, see the Justfile.

Dependencies

~0–360KB