Add missing Vector3::direction_to() and Vector2::direction_to()

This commit is contained in:
Marc Gilleron
2020-06-05 19:07:56 +01:00
parent eacffba9f5
commit 78f5496f4b
2 changed files with 12 additions and 0 deletions

View File

@@ -138,6 +138,12 @@ struct Vector2 {
return atan2(y - p_vector2.y, x - p_vector2.x);
}
inline Vector2 direction_to(const Vector2 &p_b) const {
Vector2 ret(p_b.x - x, p_b.y - y);
ret.normalize();
return ret;
}
inline real_t dot(const Vector2 &p_other) const {
return x * p_other.x + y * p_other.y;
}