refactor: Renamed Point2D to Vector2D

This commit is contained in:
Syntriax 2024-01-22 12:30:08 +03:00
parent ea92bc8c07
commit e8d0ff030a
2 changed files with 19 additions and 19 deletions

View File

@ -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;
}

View File

@ -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;
}