diff options
-rw-r--r-- | v2f.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -222,4 +222,32 @@ static inline v2f_t * v2f_nlerp(v2f_t *res, const v2f_t *a, const v2f_t *b, floa return res; } + +/* + * 1 ab-------bb + * | | | + * | | | + * | | | + * 0 aa-------ba + * t_x: 0---------1 + * ^ + * t_y + */ +static inline v2f_t _v2f_bilerp(const v2f_t *aa, const v2f_t *ab, const v2f_t *ba, const v2f_t *bb, float t_x, float t_y) +{ + v2f_t xa = _v2f_lerp(aa, ba, t_x); + v2f_t xb = _v2f_lerp(ab, bb, t_x); + + return _v2f_lerp(&xa, &xb, t_y); +} + + +static inline v2f_t * v2f_bilerp(v2f_t *res, const v2f_t *aa, const v2f_t *ab, const v2f_t *ba, const v2f_t *bb, float t_x, float t_y) +{ + if (_v2f_allocated(&res)) + *res = _v2f_bilerp(aa, ab, ba, bb, t_x, t_y); + + return res; +} + #endif |