summaryrefslogtreecommitdiff
path: root/v3f.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-05-06 18:54:19 -0700
committerVito Caputo <vcaputo@pengaru.com>2019-05-06 19:07:21 -0700
commita1be48106253be3644148d56dae122a67958c4ff (patch)
treef0eeeb506c77a40f5a2eb8adccde58d3d73f1ffa /v3f.h
parentf4cc590a4896b0a1159f13f3c367d90b7b28ade2 (diff)
v3f: add cross product: v3f_cross()
Diffstat (limited to 'v3f.h')
-rw-r--r--v3f.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/v3f.h b/v3f.h
index 7996364..ad6e373 100644
--- a/v3f.h
+++ b/v3f.h
@@ -209,4 +209,23 @@ static inline v3f_t * v3f_nlerp(v3f_t *res, const v3f_t *a, const v3f_t *b, floa
}
+static inline v3f_t _v3f_cross(const v3f_t *a, const v3f_t *b)
+{
+ return (v3f_t){
+ .x = a->y * b->z - a->z * b->y,
+ .y = a->z * b->x - a->x * b->z,
+ .z = a->x * b->y - a->y * b->x,
+ };
+}
+
+
+static inline v3f_t * v3f_cross(v3f_t *res, const v3f_t *a, const v3f_t *b)
+{
+ if (_v3f_allocated(&res))
+ *res = _v3f_cross(a, b);
+
+ return res;
+}
+
+
#endif
© All Rights Reserved