feat: FromTo Method for Vector2D
This commit is contained in:
parent
225e65fa90
commit
40e73f6b8e
|
@ -13,6 +13,8 @@ public record Vector2D(float X, float Y)
|
||||||
public static float LengthSqr(Vector2D point) => point.X * point.X + point.Y * point.Y;
|
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 Vector2D Normalize(Vector2D point) => point / Length(point);
|
||||||
|
public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from;
|
||||||
|
|
||||||
public static float Cross(Vector2D left, Vector2D right) => left.X * right.Y - left.Y * right.X;
|
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 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;
|
public static float Dot(Vector2D left, Vector2D right) => left.X * right.X + left.Y * right.Y;
|
||||||
|
|
|
@ -6,6 +6,7 @@ public static class Vector2DExtensions
|
||||||
public static float LengthSqr(this Vector2D point) => Vector2D.LengthSqr(point);
|
public static float LengthSqr(this Vector2D point) => Vector2D.LengthSqr(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 float Cross(this Vector2D left, Vector2D right) => Vector2D.Cross(left, right);
|
public static float Cross(this Vector2D left, Vector2D right) => Vector2D.Cross(left, right);
|
||||||
public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right);
|
public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right);
|
||||||
|
|
Loading…
Reference in New Issue