Vector Lerp

This commit is contained in:
Simon Lübeß
2021-08-25 22:22:59 +02:00
parent 9dbf9fd501
commit 93513f3ea8
3 changed files with 39 additions and 1 deletions
+13 -1
View File
@@ -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
+13
View File
@@ -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
+13
View File
@@ -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
//