diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 20:22:51 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 20:22:51 -0700 |
commit | 8d621db560e44be9cc40ae51956f91992fa71ff6 (patch) | |
tree | 6cbbfae157dc8d588f780e5e6b593b5788f36d92 | |
parent | 107d688e7262db5731041294df3d57b0cfd89566 (diff) |
v3f: add tri-linear interpolation: v3f_trilerp()
-rw-r--r-- | v3f.h | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -237,6 +237,33 @@ static inline v3f_t * v3f_bilerp(v3f_t *res, const v3f_t *aa, const v3f_t *ab, c } +/* + * abb-------bbb + * /| /| + * aba-------bba| + * | | | | + * |aab------|bab + * |/ |/ + * aaa-------baa + */ +static inline v3f_t _v3f_trilerp(const v3f_t *aaa, const v3f_t *aba, const v3f_t *aab, const v3f_t *abb, const v3f_t *baa, const v3f_t *bba, const v3f_t *bab, const v3f_t *bbb, float t_x, float t_y, float t_z) +{ + v3f_t xya = _v3f_bilerp(aaa, aba, baa, bba, t_x, t_y); + v3f_t xyb = _v3f_bilerp(aab, abb, bab, bbb, t_x, t_y); + + return _v3f_lerp(&xya, &xyb, t_z); +} + + +static inline v3f_t * v3f_trilerp(v3f_t *res, const v3f_t *aaa, const v3f_t *aba, const v3f_t *aab, const v3f_t *abb, const v3f_t *baa, const v3f_t *bba, const v3f_t *bab, const v3f_t *bbb, float t_x, float t_y, float t_z) +{ + if (_v3f_allocated(&res)) + *res = _v3f_trilerp(aaa, aba, aab, abb, baa, bba, bab, bbb, t_x, t_y, t_z); + + return res; +} + + static inline v3f_t _v3f_cross(const v3f_t *a, const v3f_t *b) { return (v3f_t){ |