From 015a71fc407e6cba3162b120ea20651df40e0c13 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 23 Apr 2022 23:39:50 +0200 Subject: [PATCH] Update raymath.h --- src/raymath.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index bb51586b0..21f5cf433 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -447,8 +447,7 @@ RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max) return result; } -// Clamp the magnitude of the vector between two -// given min and max values +// Clamp the magnitude of the vector between two min and max values RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max) { Vector2 result = { 0 }; @@ -942,9 +941,8 @@ RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max) return result; } -// Clamp the magnitude of the vector between two -// given min and max values -RMAPI Vector3 Vector3ClampValue(Vector3 v, float minMag, float maxMag) +// Clamp the magnitude of the vector between two values +RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max) { Vector3 result = { 0 }; @@ -953,16 +951,16 @@ RMAPI Vector3 Vector3ClampValue(Vector3 v, float minMag, float maxMag) { length = sqrtf(length); - if (length < minMag) + if (length < min) { - float scale = minMag/length; + float scale = min/length; result.x = v.x*scale; result.y = v.y*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.y = v.y*scale; result.z = v.z*scale;