#angular #units #angle #geometry #unit

angular-units

A library for representing, manipulating and converting between angular quantities in various units through a type-safe interace

9 releases

Uses old Rust 2015

0.2.4 Nov 21, 2018
0.2.3 Nov 21, 2018
0.2.2 May 28, 2017
0.2.1 Jan 5, 2017
0.1.3 Dec 30, 2016

#738 in Math

Download history 46/week @ 2023-12-10 52/week @ 2023-12-17 28/week @ 2023-12-24 15/week @ 2023-12-31 44/week @ 2024-01-07 47/week @ 2024-01-14 43/week @ 2024-01-21 26/week @ 2024-01-28 55/week @ 2024-02-04 46/week @ 2024-02-11 92/week @ 2024-02-18 52/week @ 2024-02-25 62/week @ 2024-03-03 101/week @ 2024-03-10 78/week @ 2024-03-17 101/week @ 2024-03-24

348 downloads per month
Used in 6 crates (3 directly)

MIT license

35KB
634 lines

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.

Dependencies

~135–370KB