summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-05-06 20:22:51 -0700
committerVito Caputo <vcaputo@pengaru.com>2019-05-06 20:22:51 -0700
commit8d621db560e44be9cc40ae51956f91992fa71ff6 (patch)
tree6cbbfae157dc8d588f780e5e6b593b5788f36d92
parent107d688e7262db5731041294df3d57b0cfd89566 (diff)
v3f: add tri-linear interpolation: v3f_trilerp()
-rw-r--r--v3f.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/v3f.h b/v3f.h
index aca6e1f..68f06c7 100644
--- a/v3f.h
+++ b/v3f.h
@@ -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){
© All Rights Reserved