From 38ec1bd50de234faf476daa15ea41778a860ca0b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 14 Sep 2020 20:48:49 +0300 Subject: Move a bunch of math to cpp files + small fixes --- src/math/Vector2D.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/math/Vector2D.h') diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h index 0885a5d2..0235dbe5 100644 --- a/src/math/Vector2D.h +++ b/src/math/Vector2D.h @@ -11,7 +11,13 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y); } float MagnitudeSqr(void) const { return x*x + y*y; } - void Normalise(void); + void Normalise(void) { + float sq = MagnitudeSqr(); + // assert(sq != 0.0f); // just be safe here + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + } void NormaliseSafe(void) { float sq = MagnitudeSqr(); @@ -20,7 +26,7 @@ public: x *= invsqrt; y *= invsqrt; }else - y = 1.0f; + x = 1.0f; } const CVector2D &operator+=(CVector2D const &right) { -- cgit v1.2.3