refactor: Vector2D.LengthSqr to LengthSquared

This commit is contained in:
Syntriax 2024-01-22 12:43:06 +03:00
parent 40e73f6b8e
commit a3860ddd22
2 changed files with 3 additions and 3 deletions

View File

@ -9,8 +9,8 @@ public record Vector2D(float X, float 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 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 Length(Vector2D point) => MathF.Sqrt(LengthSquared(point));
public static float LengthSqr(Vector2D point) => point.X * point.X + point.Y * point.Y; public static float LengthSquared(Vector2D point) => point.X * point.X + point.Y * point.Y;
public static Vector2D Normalize(Vector2D point) => point / Length(point); public static Vector2D Normalize(Vector2D point) => point / Length(point);
public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from; public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from;

View File

@ -3,7 +3,7 @@ namespace Syntriax.Engine.Physics2D.Primitives;
public static class Vector2DExtensions public static class Vector2DExtensions
{ {
public static float Length(this Vector2D point) => Vector2D.Length(point); public static float Length(this Vector2D point) => Vector2D.Length(point);
public static float LengthSqr(this Vector2D point) => Vector2D.LengthSqr(point); public static float LengthSquared(this Vector2D point) => Vector2D.LengthSquared(point);
public static Vector2D Normalize(this Vector2D point) => Vector2D.Normalize(point); public static Vector2D Normalize(this Vector2D point) => Vector2D.Normalize(point);
public static Vector2D FromTo(this Vector2D from, Vector2D to) => Vector2D.FromTo(from, to); public static Vector2D FromTo(this Vector2D from, Vector2D to) => Vector2D.FromTo(from, to);