diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 22:21:22 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 22:21:22 -0700 |
commit | f66c8adf48a95897f3a73132c64659cb0fc6075b (patch) | |
tree | 7d54a8f4fe5b7b8a66f96756c05c4192704f78c7 /v2f.h | |
parent | 644ab878cf20224d7e5f675089f009e796a9a8fe (diff) |
v2f: add tri-linear interpolation: v2f_trilerp()
Diffstat (limited to 'v2f.h')
-rw-r--r-- | v2f.h | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -250,4 +250,31 @@ static inline v2f_t * v2f_bilerp(v2f_t *res, const v2f_t *aa, const v2f_t *ab, c return res; } + +/* + * abb-------bbb + * /| /| + * aba-------bba| + * | | | | + * |aab------|bab + * |/ |/ + * aaa-------baa + */ +static inline v2f_t _v2f_trilerp(const v2f_t *aaa, const v2f_t *aba, const v2f_t *aab, const v2f_t *abb, const v2f_t *baa, const v2f_t *bba, const v2f_t *bab, const v2f_t *bbb, float t_x, float t_y, float t_z) +{ + v2f_t xya = _v2f_bilerp(aaa, aba, baa, bba, t_x, t_y); + v2f_t xyb = _v2f_bilerp(aab, abb, bab, bbb, t_x, t_y); + + return _v2f_lerp(&xya, &xyb, t_z); +} + + +static inline v2f_t * v2f_trilerp(v2f_t *res, const v2f_t *aaa, const v2f_t *aba, const v2f_t *aab, const v2f_t *abb, const v2f_t *baa, const v2f_t *bba, const v2f_t *bab, const v2f_t *bbb, float t_x, float t_y, float t_z) +{ + if (_v2f_allocated(&res)) + *res = _v2f_trilerp(aaa, aba, aab, abb, baa, bba, bab, bbb, t_x, t_y, t_z); + + return res; +} + #endif |