diff --git a/Game/Physics2D/Primitives/Vector2D.cs b/Game/Physics2D/Primitives/Vector2D.cs index 186fdaa..565140a 100644 --- a/Game/Physics2D/Primitives/Vector2D.cs +++ b/Game/Physics2D/Primitives/Vector2D.cs @@ -12,6 +12,8 @@ public record Vector2D(float X, float Y) public static float Length(Vector2D point) => MathF.Sqrt(LengthSquared(point)); public static float LengthSquared(Vector2D point) => point.X * point.X + point.Y * point.Y; + public static float Distance(Vector2D from, Vector2D to) => Length(FromTo(from, to)); + public static Vector2D Normalize(Vector2D point) => point / Length(point); public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from; diff --git a/Game/Physics2D/Primitives/Vector2DExtensions.cs b/Game/Physics2D/Primitives/Vector2DExtensions.cs index 97389df..0d2e733 100644 --- a/Game/Physics2D/Primitives/Vector2DExtensions.cs +++ b/Game/Physics2D/Primitives/Vector2DExtensions.cs @@ -4,6 +4,7 @@ public static class Vector2DExtensions { public static float Length(this Vector2D point) => Vector2D.Length(point); public static float LengthSquared(this Vector2D point) => Vector2D.LengthSquared(point); + public static float Distance(this Vector2D from, Vector2D to) => Vector2D.LengthSquared(point); public static Vector2D Normalize(this Vector2D point) => Vector2D.Normalize(point); public static Vector2D FromTo(this Vector2D from, Vector2D to) => Vector2D.FromTo(from, to);