Function pix_engine::math::lerp_map

source ·
pub fn lerp_map<T>(start1: T, end1: T, start2: T, end2: T) -> Vec<T>
where T: Num + NumCast + Copy + PartialOrd + AddAssign,
Expand description

Linear interpolates values for a range of independent values based on depdendent values.

Examples

use pix_engine::math::lerp_map;

let x1 = 0;
let x2 = 5;
let y1 = 0;
let y2 = 10;
let values = lerp_map(x1, x2, y1, y2);
assert_eq!(values, vec![0, 2, 4, 6, 8, 10]);

let x1 = 0.0;
let x2 = 4.0;
let y1 = 0.0;
let y2 = 14.0;
let values = lerp_map(x1, x2, y1, y2);
assert_eq!(values, vec![0.0, 3.5, 7.0, 10.5, 14.0]);