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
use core::ops::{AddAssign, MulAssign, Sub};
use cast_trait::Cast;
use super::{add_mut, smul_mut, sub};
#[inline]
pub fn lerp<'out, T, F>(out: &'out mut [T; 2], a: &[T; 2], b: &[T; 2], t: &F) -> &'out mut [T; 2]
where
T: Clone + Cast<F>,
F: Clone + Cast<T>,
for<'a> T: AddAssign<&'a T>,
for<'a> F: MulAssign<&'a F>,
for<'a, 'b> &'a T: Sub<&'b T, Output = T>,
{
let mut tmp = out.clone();
sub(&mut tmp, b, a);
let mut tmp_f: [F; 2] = tmp.cast();
smul_mut(&mut tmp_f, t);
tmp = tmp_f.cast();
add_mut(out, &tmp);
out
}