Crates.io | angular |
lib.rs | angular |
version | 0.1.1 |
source | src |
created_at | 2015-08-26 13:50:14.71631 |
updated_at | 2015-12-11 23:57:25.953017 |
description | Angular types and common helper methods. |
homepage | https://github.com/b52/angular-rust |
repository | https://github.com/b52/angular-rust.git |
max_upload_size | |
id | 2925 |
size | 15,610 |
Angular types and common helper methods to work with them while using the Rust type system in our favor.
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 angular;
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);
For an exhaustive documentation head over to the API docs.
This software is licensed under the terms of the MIT license. Please see the LICENSE for full details.