Reviewed some functions to avoid calling other functions

This commit is contained in:
raysan5 2021-07-29 21:50:50 +02:00
parent 6ef3ab3d3a
commit 58e9a0894f

View File

@ -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;