Update raymath.h

This commit is contained in:
Ray 2022-04-23 23:39:50 +02:00
parent be3ae71aec
commit 015a71fc40

View file

@ -447,8 +447,7 @@ RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)
return result; return result;
} }
// Clamp the magnitude of the vector between two // Clamp the magnitude of the vector between two min and max values
// given min and max values
RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max) RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
{ {
Vector2 result = { 0 }; Vector2 result = { 0 };
@ -942,9 +941,8 @@ RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max)
return result; return result;
} }
// Clamp the magnitude of the vector between two // Clamp the magnitude of the vector between two values
// given min and max values RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
RMAPI Vector3 Vector3ClampValue(Vector3 v, float minMag, float maxMag)
{ {
Vector3 result = { 0 }; Vector3 result = { 0 };
@ -953,16 +951,16 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float minMag, float maxMag)
{ {
length = sqrtf(length); length = sqrtf(length);
if (length < minMag) if (length < min)
{ {
float scale = minMag/length; float scale = min/length;
result.x = v.x*scale; result.x = v.x*scale;
result.y = v.y*scale; result.y = v.y*scale;
result.z = v.z*scale; result.z = v.z*scale;
} }
else if (length > maxMag) else if (length > max)
{ {
float scale = maxMag/length; float scale = max/length;
result.x = v.x*scale; result.x = v.x*scale;
result.y = v.y*scale; result.y = v.y*scale;
result.z = v.z*scale; result.z = v.z*scale;