diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-08 12:00:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 12:00:54 +0200 |
commit | 7f3373d79f017c17ad5ffd0eba877fc056ad649b (patch) | |
tree | b78f9874fe96e979edf8cab43da744dcb94bd0ab /modules/mono | |
parent | a994db62df731879bb9c54e65b4ddca32396e9d3 (diff) | |
parent | 55f3bd97a270b691c26d6eda70bc7c0a3ec8f4e8 (diff) |
Merge pull request #27452 from Chaosus/direction_to
Added method to retrieve a direction vector from one point to another
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector2.cs | 5 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/Vector3.cs | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/modules/mono/glue/Managed/Files/Vector2.cs b/modules/mono/glue/Managed/Files/Vector2.cs index 73a3252fdb..908162ec45 100644 --- a/modules/mono/glue/Managed/Files/Vector2.cs +++ b/modules/mono/glue/Managed/Files/Vector2.cs @@ -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); diff --git a/modules/mono/glue/Managed/Files/Vector3.cs b/modules/mono/glue/Managed/Files/Vector3.cs index f6ff27989d..0c96d346a9 100644 --- a/modules/mono/glue/Managed/Files/Vector3.cs +++ b/modules/mono/glue/Managed/Files/Vector3.cs @@ -126,6 +126,11 @@ namespace Godot ); } + public Vector3 DirectionTo(Vector3 b) + { + return new Vector3(b.x - x, b.y - y, b.z - z).Normalized(); + } + public real_t DistanceSquaredTo(Vector3 b) { return (b - this).LengthSquared(); |