6 releases (breaking)

0.6.0 Feb 25, 2022
0.5.0 Jul 14, 2021
0.4.0 Nov 13, 2020
0.3.0 Feb 7, 2019
0.1.0 Mar 17, 2017

#944 in Algorithms

Download history 20/week @ 2024-07-22 127/week @ 2024-07-29 33/week @ 2024-08-05 38/week @ 2024-08-12 15/week @ 2024-08-19 64/week @ 2024-08-26 73/week @ 2024-09-02 38/week @ 2024-09-09 150/week @ 2024-09-16 269/week @ 2024-09-23 90/week @ 2024-09-30 22/week @ 2024-10-07 35/week @ 2024-10-14 352/week @ 2024-10-21 6/week @ 2024-10-28 18/week @ 2024-11-04

412 downloads per month
Used in 9 crates (4 directly)

MIT license

24KB
548 lines

Ang

Ang is a fork of the Angular crate to add various improvements.

Angular types and common helper methods to work with them while using the Rust type system in our favor.

Features

  • Tested and documented,
  • Safety without sacrificing performance and conversion related errors,

Usage

Everything evolves around the Angle<T> type and its two variants Degrees(v) and Radians(v). This ensures proper typing and allows for safe helper methods evolving around it.

extern crate ang;

use angular::*;
use std::f64::consts::{SQRT_2, FRAC_PI_4};

fn calc_hypotenuse(opposite: f64, alpha: Angle) -> f64 {
    opposite / alpha.sin()
}

let a = calc_hypotenuse(SQRT_2, Radians(FRAC_PI_4));
let b = calc_hypotenuse(SQRT_2, Degrees(45.0));
let c = calc_hypotenuse(SQRT_2, Angle::eighth());

assert!((a - 2.0).abs() < 1.0e10);
assert!((a - b).abs() < 1.0e10);

Features

std

Enabling the std feature will link this crate to std. If this feature is disabled, then this crate will be built with #![no_std] enabled.

This feature is enabled by default.

Documentation

For an exhaustive documentation head over to the API docs.

License

This software is licensed under the terms of the MIT license. Please see the LICENSE for full details.

Dependencies

~130–350KB