diff options
-rw-r--r-- | v3f.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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)); |