summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--v2f.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/v2f.h b/v2f.h
index 382b5b0..93175a2 100644
--- a/v2f.h
+++ b/v2f.h
@@ -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
© All Rights Reserved