angular-units

Crates.ioangular-units
lib.rsangular-units
version0.2.4
sourcesrc
created_at2016-12-28 03:12:38.836966
updated_at2018-11-21 19:24:58.580758
descriptionA library for representing, manipulating and converting between angular quantities in various units through a type-safe interace.
homepagehttps://github.com/tylerreisinger/rust-angular-units
repositoryhttps://github.com/tylerreisinger/rust-angular-units
max_upload_size
id7810
size36,516
Tyler Reisinger (tylerreisinger)

documentation

https://docs.rs/angular-units/

README

angular-units 0.2.4

Build Status angular-units on docs.rs angular-units on crates.io

Feature-rich library for representing and manipulating angular quantities. Provides strongly-typed structs for six units as well as helper traits for abstracting over the concrete types and doing common operations.

Provided Units:

  • Degrees - Deg<T>
  • Radians - Rad<T>
  • Gradians - Gon<T>
  • Turns - Turns<T> (1 turn is a full rotation)
  • Arc minutes - ArcMinutes<T>
  • Arc seconds - ArcSeconds<T>

Usage:

[dependencies]
angular-units = "0.2.4"

Examples:

  • Converting from Degrees to Radians:
  let angle = Deg(45.0);
  let radians: Rad<_> = angle.into_angle();
  • Composing angles from multiple units:
  let degrees: Deg<f32> = Deg(50.0_f32) + ArcMinutes(25.0_f32) + Rad(std::f32::consts::PI / 6.0_f32);
  • Interpolating between two angles:
 assert_eq!(Deg(240.0).interpolate(&Deg(180.0), 0.5), Deg(210.0))

Optional Features:

Angular-units provides optional serde and approx support for all types by enabling their respective features.

Commit count: 56

cargo fmt