diff --git a/include/Vector2.h b/include/Vector2.h index ec8d274..e9bd353 100644 --- a/include/Vector2.h +++ b/include/Vector2.h @@ -217,6 +217,7 @@ public: /// Value -1 is *from* vector minus the difference between *from* and *to* etc. static Vector2 Lerp(Vector2 from, Vector2 to, float f); + static float ToFactor(Vector2 a, Vector2 b); }; #endif \ No newline at end of file diff --git a/src/Vector2.cpp b/src/Vector2.cpp index 971ecab..3613cc2 100644 --- a/src/Vector2.cpp +++ b/src/Vector2.cpp @@ -120,7 +120,11 @@ float Vector2::SignedAngle(Vector2 from, Vector2 to) { return (angleTo - angleFrom) * Rad2Deg; } -static Vector2 Lerp(Vector2 from, Vector2 to, float f) { +Vector2 Vector2::Lerp(Vector2 from, Vector2 to, float f) { Vector2 v = from + (to - from) * f; return v; } + +float Vector2::ToFactor(Vector2 a, Vector2 b) { + return (1 - Vector2::Dot(a, b)) / 2; +} diff --git a/test/Vector2_test.cc b/test/Vector2_test.cc index 45b2871..26a9324 100644 --- a/test/Vector2_test.cc +++ b/test/Vector2_test.cc @@ -417,8 +417,10 @@ TEST(Vector2, SignedAngle) { } } -//TEST(Vector2, DISABLED_Lerp) { -// -//} +TEST(Vector2, DISABLED_Lerp) { +} + +TEST(Vector2, DIABLED_ToFactor) { +} #endif \ No newline at end of file