summaryrefslogtreecommitdiffstats
path: root/include/core/Vector2.hpp
diff options
context:
space:
mode:
authorMarc Gilleron <marc.gilleron@gmail.com>2020-06-05 19:07:56 +0100
committerMarc Gilleron <marc.gilleron@gmail.com>2020-06-05 19:07:56 +0100
commit78f5496f4b9986bb390926fb4cb78e646c89c972 (patch)
tree88ff1406592ea0387860274eea0873bd447e8dbf /include/core/Vector2.hpp
parenteacffba9f5dc960e741e43670f1b9c2cb7c9fa08 (diff)
downloadredot-cpp-78f5496f4b9986bb390926fb4cb78e646c89c972.tar.gz
Add missing Vector3::direction_to() and Vector2::direction_to()
Diffstat (limited to 'include/core/Vector2.hpp')
-rw-r--r--include/core/Vector2.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp
index 99ac60f..2a4f5fe 100644
--- a/include/core/Vector2.hpp
+++ b/include/core/Vector2.hpp
@@ -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;
}