diff --git a/include/Vector3.h b/include/Vector3.h index df1d0e6..15d05e9 100644 --- a/include/Vector3.h +++ b/include/Vector3.h @@ -197,8 +197,6 @@ public: /// The cross product of the two vectors static Vector3 Cross(const Vector3& vector1, const Vector3& vector2); - // Projects a vector onto another vector. - /// /// Project a vector on another vector /// @@ -233,4 +231,16 @@ public: /// The axis to rotate around /// The signed angle static float SignedAngle(Vector3 from, Vector3 to, Vector3 axis); + + + /// + /// Lerp between two vectors + /// + /// The from vector + /// The to vector + /// The interpolation distance (0..1) + /// The lerped vector + /// 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); }; diff --git a/src/Vector3.cpp b/src/Vector3.cpp index b0a177d..cda2a6d 100644 --- a/src/Vector3.cpp +++ b/src/Vector3.cpp @@ -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; +} \ No newline at end of file diff --git a/test/Vector3_test.cc b/test/Vector3_test.cc index 3545a32..0a42c57 100644 --- a/test/Vector3_test.cc +++ b/test/Vector3_test.cc @@ -523,4 +523,8 @@ TEST(Vector3, SignedAngle) { EXPECT_TRUE(r) << "SignedAngle(4 5 6, -INFINITY -INFINITY -INFINITY)"; } +} + +TEST(Vector3, DISABLED_Lerp) { + } \ No newline at end of file