From 86aa0950bd8c25da78fe1fc05b2a7b5f7eaa8b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nilso=20J=C3=BAnior?= <162613094+nilsojunior@users.noreply.github.com> Date: Thu, 16 Apr 2026 03:37:04 -0300 Subject: [PATCH] [raymath] Refactor `QuaternionFromAxisAngle` (#5766) Checking if lenght equals 0 inside the if statement is not necessary. --- src/raymath.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 3d59266c5..9398258dd 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -2505,19 +2505,14 @@ RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) { Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; - float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); + float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); - if (axisLength != 0.0f) + if (length != 0.0f) { angle *= 0.5f; - float length = 0.0f; - float ilength = 0.0f; - // Vector3Normalize(axis) - length = axisLength; - if (length == 0.0f) length = 1.0f; - ilength = 1.0f/length; + float ilength = 1.0f/length; axis.x *= ilength; axis.y *= ilength; axis.z *= ilength;