1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Added direction_to method to vectors

(cherry picked from commit 55f3bd97a2)
This commit is contained in:
Chaosus
2019-03-27 13:51:05 +03:00
committed by Hein-Pieter van Braam-Stewart
parent 9535a6079e
commit 340bf6e80c
7 changed files with 46 additions and 0 deletions

View File

@@ -132,6 +132,11 @@ namespace Godot
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
}
public Vector2 DirectionTo(Vector2 b)
{
return new Vector2(b.x - x, b.y - y).Normalized();
}
public real_t DistanceSquaredTo(Vector2 to)
{
return (x - to.x) * (x - to.x) + (y - to.y) * (y - to.y);