diff --git a/GlitchyEngine/src/Math/Vector2.bf b/GlitchyEngine/src/Math/Vector2.bf index 010aee9..945d748 100644 --- a/GlitchyEngine/src/Math/Vector2.bf +++ b/GlitchyEngine/src/Math/Vector2.bf @@ -145,7 +145,19 @@ namespace GlitchyEngine.Math { return (a - b * (Dot(a, b) / Dot(b, b))); } - + + /** + * Interpolates linearly between two given vectors. + * @param a The first vector. + * @param b The second vector. + * @param interpolationValue The value that linearly interpolates between a and b. + * (0 means a will be returned, 1 means b will be returned.) + * @returns The resulting linear interpolation. + */ + public static Vector2 Lerp(Vector2 a, Vector2 b, float interpolationValue) + { + return a + interpolationValue * (b - a); + } // // Assignment operators diff --git a/GlitchyEngine/src/Math/Vector3.bf b/GlitchyEngine/src/Math/Vector3.bf index 500e44c..3f037b3 100644 --- a/GlitchyEngine/src/Math/Vector3.bf +++ b/GlitchyEngine/src/Math/Vector3.bf @@ -180,6 +180,19 @@ namespace GlitchyEngine.Math { return .(Math.Floor(value.X), Math.Floor(value.Y), Math.Floor(value.Z)); } + + /** + * Interpolates linearly between two given vectors. + * @param a The first vector. + * @param b The second vector. + * @param interpolationValue The value that linearly interpolates between a and b. + * (0 means a will be returned, 1 means b will be returned.) + * @returns The resulting linear interpolation. + */ + public static Vector3 Lerp(Vector3 a, Vector3 b, float interpolationValue) + { + return a + interpolationValue * (b - a); + } // // Assignment operators diff --git a/GlitchyEngine/src/Math/Vector4.bf b/GlitchyEngine/src/Math/Vector4.bf index 428e9f8..07dfdb2 100644 --- a/GlitchyEngine/src/Math/Vector4.bf +++ b/GlitchyEngine/src/Math/Vector4.bf @@ -166,6 +166,19 @@ namespace GlitchyEngine.Math return (a - b * (Dot(a, b) / Dot(b, b))); } + /** + * Interpolates linearly between two given vectors. + * @param a The first vector. + * @param b The second vector. + * @param interpolationValue The value that linearly interpolates between a and b. + * (0 means a will be returned, 1 means b will be returned.) + * @returns The resulting linear interpolation. + */ + public static Vector4 Lerp(Vector4 a, Vector4 b, float interpolationValue) + { + return a + interpolationValue * (b - a); + } + // // Assignment operators //