aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2018-08-21 16:29:10 +0200
committerGitHub <noreply@github.com>2018-08-21 16:29:10 +0200
commit4259ff78e1d8df8818de178d819cb42a85694595 (patch)
tree9bb92b8abc3d79cedb271723fce5075f02720dfc
parent20656af122d0d3d3be87ee84bff3a1a76eb1a3bb (diff)
parent2bef76735dc8748e0f545a8d415ac1a6ec2bbfc5 (diff)
downloadraylib-4259ff78e1d8df8818de178d819cb42a85694595.tar.gz
raylib-4259ff78e1d8df8818de178d819cb42a85694595.zip
Merge pull request #633 from unequaled86/patch-1
lerp for vector2 and float
-rw-r--r--src/raymath.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/raymath.h b/src/raymath.h
index dfc43181..c5c6588f 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -155,6 +155,12 @@ RMDEF float Clamp(float value, float min, float max)
return res > max ? max : res;
}
+// Calculate linear interpolation between two vectors
+RMDEF float Lerp(float start, float end, float amount)
+{
+ return start + amount*(end - start);
+}
+
//----------------------------------------------------------------------------------
// Module Functions Definition - Vector2 math
//----------------------------------------------------------------------------------
@@ -244,6 +250,17 @@ RMDEF Vector2 Vector2Normalize(Vector2 v)
return result;
}
+// Calculate linear interpolation between two vectors
+RMDEF Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
+{
+ Vector2 result = { 0 };
+
+ result.x = v1.x + amount*(v2.x - v1.x);
+ result.y = v1.y + amount*(v2.y - v1.y);
+
+ return result;
+}
+
//----------------------------------------------------------------------------------
// Module Functions Definition - Vector3 math
//----------------------------------------------------------------------------------