diff options
Diffstat (limited to 'v3f.h')
-rw-r--r-- | v3f.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -209,6 +209,34 @@ static inline v3f_t * v3f_nlerp(v3f_t *res, const v3f_t *a, const v3f_t *b, floa } +/* + * 1 ab-------bb + * | | | + * | | | + * | | | + * 0 aa-------ba + * t_x: 0---------1 + * ^ + * t_y + */ +static inline v3f_t _v3f_bilerp(const v3f_t *aa, const v3f_t *ab, const v3f_t *ba, const v3f_t *bb, float t_x, float t_y) +{ + v3f_t xa = _v3f_lerp(aa, ba, t_x); + v3f_t xb = _v3f_lerp(ab, bb, t_x); + + return _v3f_lerp(&xa, &xb, t_y); +} + + +static inline v3f_t * v3f_bilerp(v3f_t *res, const v3f_t *aa, const v3f_t *ab, const v3f_t *ba, const v3f_t *bb, float t_x, float t_y) +{ + if (_v3f_allocated(&res)) + *res = _v3f_bilerp(aa, ab, ba, bb, t_x, t_y); + + return res; +} + + static inline v3f_t _v3f_cross(const v3f_t *a, const v3f_t *b) { return (v3f_t){ |