diff options
-rw-r--r-- | v2f.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -157,6 +157,20 @@ static inline float v2f_length(const v2f_t *v) } +static inline float v2f_distance(const v2f_t *a, const v2f_t *b) +{ + return v2f_length(v2f_sub(&(v2f_t){}, a, b)); +} + + +static inline float v2f_distance_sq(const v2f_t *a, const v2f_t *b) +{ + v2f_t d = _v2f_sub(a, b); + + return v2f_dot(&d, &d); +} + + static inline v2f_t _v2f_normalize(const v2f_t *v) { return _v2f_mult_scalar(v, 1.0f / v2f_length(v)); |