diff options
| author | raysan5 <[email protected]> | 2021-07-29 21:50:50 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2021-07-29 21:50:50 +0200 |
| commit | 58e9a0894f65a50004e637f7db72bd12da809cd9 (patch) | |
| tree | a322c662e7d4d42b4d94d1163857af3b5c2dbdf5 /src | |
| parent | 6ef3ab3d3ac98f2e8a77b4bd065008d2ce9d7e8f (diff) | |
| download | raylib-58e9a0894f65a50004e637f7db72bd12da809cd9.tar.gz raylib-58e9a0894f65a50004e637f7db72bd12da809cd9.zip | |
Reviewed some functions to avoid calling other functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/raymath.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/raymath.h b/src/raymath.h index 3b65e382..ffdd2c27 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raymath v1.2 - Math functions to work with Vector3, Matrix and Quaternions +* raymath v1.3 - Math functions to work with Vector3, Matrix and Quaternions * * CONFIGURATION: * @@ -488,14 +488,14 @@ RMDEF Vector3 Vector3Normalize(Vector3 v) { Vector3 result = v; - float length, ilength; - length = Vector3Length(v); + float length, inverseLength; + length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); if (length == 0.0f) length = 1.0f; - ilength = 1.0f/length; + inverseLength = 1.0f/length; - result.x *= ilength; - result.y *= ilength; - result.z *= ilength; + result.x *= inverseLength; + result.y *= inverseLength; + result.z *= inverseLength; return result; } @@ -1429,8 +1429,9 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q) RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) { Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; - - if (Vector3Length(axis) != 0.0f) + float axisLength = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); + + if (axisLength != 0.0f) { angle *= 0.5f; |
