Added Vector3::Lerp (unit test omitted for now)

This commit is contained in:
Pascal Serrarens 2022-01-28 15:48:21 +01:00
parent 0f46f06ed5
commit eb3c7805a3
3 changed files with 21 additions and 2 deletions

View File

@ -197,8 +197,6 @@ public:
/// <returns>The cross product of the two vectors</returns>
static Vector3 Cross(const Vector3& vector1, const Vector3& vector2);
// Projects a vector onto another vector.
/// <summary>
/// Project a vector on another vector
/// </summary>
@ -233,4 +231,16 @@ public:
/// <param name="axis">The axis to rotate around</param>
/// <returns>The signed angle</returns>
static float SignedAngle(Vector3 from, Vector3 to, Vector3 axis);
/// <summary>
/// Lerp between two vectors
/// </summary>
/// <param name="from">The from vector</param>
/// <param name="to">The to vector</param>
/// <param name="f">The interpolation distance (0..1)</param>
/// <returns>The lerped vector</returns>
/// The factor f is unclamped. Value 0 matches the *from* vector, Value 1 matches the *to* vector
/// Value -1 is *from* vector minus the difference between *from* and *to* etc.
static Vector3 Lerp(Vector3 from, Vector3 to, float f);
};

View File

@ -160,3 +160,8 @@ float Vector3::SignedAngle(Vector3 from, Vector3 to, Vector3 axis) {
return signed_angle;
}
Vector3 Vector3::Lerp(Vector3 from, Vector3 to, float f) {
Vector3 v = from + (to - from) * f;
return v;
}

View File

@ -523,4 +523,8 @@ TEST(Vector3, SignedAngle) {
EXPECT_TRUE(r) << "SignedAngle(4 5 6, -INFINITY -INFINITY -INFINITY)";
}
}
TEST(Vector3, DISABLED_Lerp) {
}