From d23aa08f8ce84d747db838cfe3291b6ae74deb33 Mon Sep 17 00:00:00 2001 From: cypress Date: Sat, 22 Jul 2023 12:08:28 -0400 Subject: [PATCH] Use a macro for Length --- source/mathlib.c | 13 ------------- source/mathlib.h | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/source/mathlib.c b/source/mathlib.c index 355d97a..41e9f94 100644 --- a/source/mathlib.c +++ b/source/mathlib.c @@ -430,19 +430,6 @@ void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross) double sqrt(double x); -vec_t Length(vec3_t v) -{ - int i; - float length; - - length = 0; - for (i=0 ; i< 3 ; i++) - length += v[i]*v[i]; - length = sqrt (length); // FIXME - - return length; -} - float VecLength2(vec3_t v1, vec3_t v2) { vec3_t k; diff --git a/source/mathlib.h b/source/mathlib.h index 4d95745..bdce716 100644 --- a/source/mathlib.h +++ b/source/mathlib.h @@ -72,7 +72,7 @@ do { \ } while(0) int VectorCompare (vec3_t v1, vec3_t v2); -vec_t Length (vec3_t v); +#define Length(v) (sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])) void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross); float VectorLength (vec3_t v); float VecLength2(vec3_t v1, vec3_t v2);