From 3cb4ef25990d88cf5c9170cf5c571f5968204be9 Mon Sep 17 00:00:00 2001 From: HarriP <HarriP@users.noreply.github.com> Date: Mon, 6 Dec 2021 20:07:05 +0200 Subject: [PATCH] Fix inverse length in Vector2Normalize (#2189) Following the pattern in Vector3Normalize. --- src/raymath.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 399c2f6c0..898e48aed 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -328,8 +328,9 @@ RMAPI Vector2 Vector2Normalize(Vector2 v) if (length > 0) { - result.x = v.x*1.0f/length; - result.y = v.y*1.0f/length; + float ilength = 1.0f / length; + result.x = v.x * ilength; + result.y = v.y * ilength; } return result;