Trait lib_rapid::math::rapidmath::MapToNumRange [−][src]
pub trait MapToNumRange<T> {
fn map_to(&self, start1: T, end1: T, start2: T, end2: T) -> T;
}
Expand description
Trait for mapping numbers to another number range.
Required methods
Maps a given number of a range onto another range.
Arguments
start1
- The original start value of the number range.end1
- The original end value of the number range.start2
- The new start value of the number range.end2
- The new start value of the number range.
Returns
A number containing the new mapped value.
Examples
use lib_rapid::math::rapidmath::MapToNumRange;
let result: f32 = 5f32.map_to(0., 10., 0., 1.); // Original value 5 in the range from 0-10
std::println!("{}", result.to_string()) // Prints "0.5"