diff --git a/Game/Physics2D/Primitives/Point2D.cs b/Game/Physics2D/Primitives/Point2D.cs deleted file mode 100644 index d344a34..0000000 --- a/Game/Physics2D/Primitives/Point2D.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Syntriax.Engine.Physics2D.Primitives; - -public record Point2D(float X, float Y) -{ - public static Point2D operator +(Point2D left, Point2D right) => new(left.X + right.X, left.Y + right.Y); - public static Point2D operator -(Point2D left, Point2D right) => new(left.X - right.X, left.Y - right.Y); - public static Point2D operator *(Point2D point, float value) => new(point.X * value, point.Y * value); - public static Point2D operator /(Point2D point, float value) => new(point.X / value, point.Y / value); - - public static float Length(Point2D point) => MathF.Sqrt(LengthSqr(point)); - public static float LengthSqr(Point2D point) => point.X * point.X + point.Y * point.Y; - - public static Point2D Normalize(Point2D point) => point / Length(point); - public static float Cross(Point2D left, Point2D right) => left.X * right.Y - left.Y * right.X; - public static float Angle(Point2D left, Point2D right) => MathF.Acos(Dot(left, right) / (Length(left) * Length(right))); - public static float Dot(Point2D left, Point2D right) => left.X * right.X + left.Y * right.Y; -} diff --git a/Game/Physics2D/Primitives/Vector2D.cs b/Game/Physics2D/Primitives/Vector2D.cs new file mode 100644 index 0000000..ece82f3 --- /dev/null +++ b/Game/Physics2D/Primitives/Vector2D.cs @@ -0,0 +1,19 @@ +using System; + +namespace Syntriax.Engine.Physics2D.Primitives; + +public record Vector2D(float X, float Y) +{ + public static Vector2D operator +(Vector2D left, Vector2D right) => new(left.X + right.X, left.Y + right.Y); + public static Vector2D operator -(Vector2D left, Vector2D right) => new(left.X - right.X, left.Y - right.Y); + public static Vector2D operator *(Vector2D point, float value) => new(point.X * value, point.Y * value); + public static Vector2D operator /(Vector2D point, float value) => new(point.X / value, point.Y / value); + + public static float Length(Vector2D point) => MathF.Sqrt(LengthSqr(point)); + public static float LengthSqr(Vector2D point) => point.X * point.X + point.Y * point.Y; + + public static Vector2D Normalize(Vector2D point) => point / Length(point); + public static float Cross(Vector2D left, Vector2D right) => left.X * right.Y - left.Y * right.X; + public static float Angle(Vector2D left, Vector2D right) => MathF.Acos(Dot(left, right) / (Length(left) * Length(right))); + public static float Dot(Vector2D left, Vector2D right) => left.X * right.X + left.Y * right.Y; +}