summaryrefslogtreecommitdiff
path: root/v3f.h
diff options
context:
space:
mode:
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