summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--v3f.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/v3f.h b/v3f.h
index 3011182..d169e76 100644
--- a/v3f.h
+++ b/v3f.h
@@ -157,6 +157,20 @@ static inline float v3f_length(const v3f_t *v)
}
+static inline float v3f_distance(const v3f_t *a, const v3f_t *b)
+{
+ return v3f_length(v3f_sub(&(v3f_t){}, a, b));
+}
+
+
+static inline float v3f_distance_sq(const v3f_t *a, const v3f_t *b)
+{
+ v3f_t d = _v3f_sub(a, b);
+
+ return v3f_dot(&d, &d);
+}
+
+
static inline v3f_t _v3f_normalize(const v3f_t *v)
{
return _v3f_mult_scalar(v, 1.0f / v3f_length(v));
© All Rights Reserved