-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmod.rs
More file actions
40 lines (35 loc) · 997 Bytes
/
mod.rs
File metadata and controls
40 lines (35 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Lambda Math Types and operations
pub mod error;
pub mod matrix;
pub mod vector;
pub use error::MathError;
/// Angle units used by conversion helpers and matrix transforms.
///
/// Prefer `Angle::Turns` for ergonomic quarter/half rotations when building
/// camera and model transforms. One full turn equals `2π` radians.
pub enum Angle {
/// Angle expressed in radians.
Radians(f32),
/// Angle expressed in degrees.
Degrees(f32),
/// Angle expressed in turns, where `1.0` is a full revolution.
Turns(f32),
}
/// Convert a turn into radians.
fn turns_to_radians(turns: f32) -> f32 {
return turns * std::f32::consts::PI * 2.0;
}
#[macro_export]
/// Assert that two values are equal, with a given tolerance.
macro_rules! assert_approximately_equal {
($a:expr, $b:expr, $eps:expr) => {{
let (a, b, eps) = ($a, $b, $eps);
assert!(
(a - b).abs() < eps,
"{} is not approximately equal to {} with an epsilon of {}",
a,
b,
eps
);
}};
}