No warnings ! Starts csma-like behaviour
This commit is contained in:
9
src/math.rs
Normal file
9
src/math.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use std::ops::{Add, Mul, Sub, Div};
|
||||
|
||||
// Useful math used throughout
|
||||
pub fn map<T>(input: T, in_min: T, in_max: T, out_min: T, out_max: T) -> T
|
||||
where
|
||||
T: Clone + Add<Output = T> + Mul<Output = T> + Sub<Output = T> + Div<Output = T>,
|
||||
{
|
||||
((input - in_min.clone()) / (in_max - in_min)) * (out_max - out_min.clone()) + out_min
|
||||
}
|
||||
Reference in New Issue
Block a user