Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[raymath.h] Small code refactor #3753

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/raymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ typedef struct float16 {
// Clamp float value
RMAPI float Clamp(float value, float min, float max)
{
float result = (value < min)? min : value;
float result = (value < min) ? min : value;

if (result > max) result = max;

Expand Down Expand Up @@ -494,18 +494,18 @@ RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
{
length = sqrtf(length);

float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
float scale = min/length;
result.x = v.x*scale;
result.y = v.y*scale;
scale = min/length;
}
else if (length > max)
{
float scale = max/length;
result.x = v.x*scale;
result.y = v.y*scale;
scale = max/length;
}

result.x = v.x*scale;
result.y = v.y*scale;
}

return result;
Expand Down Expand Up @@ -834,7 +834,7 @@ RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle)
// Vector3Normalize(axis);
float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
if (length == 0.0f) length = 1.0f;
float ilength = 1.0f / length;
float ilength = 1.0f/length;
axis.x *= ilength;
axis.y *= ilength;
axis.z *= ilength;
Expand Down Expand Up @@ -1080,20 +1080,19 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
{
length = sqrtf(length);

float scale = 1; // By default, 1 as the neutral element.
if (length < min)
{
float scale = min/length;
result.x = v.x*scale;
result.y = v.y*scale;
result.z = v.z*scale;
scale = min/length;
}
else if (length > max)
{
float scale = max/length;
result.x = v.x*scale;
result.y = v.y*scale;
result.z = v.z*scale;
scale = max/length;
}

result.x = v.x*scale;
result.y = v.y*scale;
result.z = v.z*scale;
}

return result;
Expand Down Expand Up @@ -1962,7 +1961,7 @@ RMAPI Quaternion QuaternionFromMatrix(Matrix mat)
}

float biggestVal = sqrtf(fourBiggestSquaredMinus1 + 1.0f)*0.5f;
float mult = 0.25f / biggestVal;
float mult = 0.25f/biggestVal;

switch (biggestIndex)
{
Expand Down
Loading