Added ToFactor function

This commit is contained in:
Pascal Serrarens 2022-03-17 15:46:06 +01:00
parent c2b5791f53
commit 307a94c567
3 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -417,8 +417,10 @@ TEST(Vector2, SignedAngle) {
}
}
//TEST(Vector2, DISABLED_Lerp) {
//
//}
TEST(Vector2, DISABLED_Lerp) {
}
TEST(Vector2, DIABLED_ToFactor) {
}
#endif