[vec.c] Linear interpolation properly implemented
This commit is contained in:
parent
58cb48fa75
commit
62d637969d
|
@ -32,9 +32,13 @@ void vec_div(Vec *vector, float scale)
|
|||
|
||||
void vec_lerp(Vec *from, Vec to, float scale)
|
||||
{
|
||||
Vec temp = {};
|
||||
/* from * (1 - scale) + temp * scale */
|
||||
Vec temp;
|
||||
vec_cpy(&temp, to);
|
||||
vec_sub(&temp, *from);
|
||||
/* from * (1 - scale) */
|
||||
vec_mul(from, 1 - scale);
|
||||
/* temp * scale */
|
||||
vec_mul(&temp, scale);
|
||||
/* add */
|
||||
vec_add(from, temp);
|
||||
}
|
||||
|
|
Reference in New Issue