feat: Basic Operation Methods
Vector2D.Invert Vector2D.Add Vector2D.Subtract Vector2D.Multiply Vector2D.Subdivide
This commit is contained in:
parent
1acecdf3ce
commit
83d8a03be3
|
@ -4,8 +4,15 @@ public static class Vector2DExtensions
|
||||||
{
|
{
|
||||||
public static float Length(this Vector2D vector) => Vector2D.Length(vector);
|
public static float Length(this Vector2D vector) => Vector2D.Length(vector);
|
||||||
public static float LengthSquared(this Vector2D vector) => Vector2D.LengthSquared(vector);
|
public static float LengthSquared(this Vector2D vector) => Vector2D.LengthSquared(vector);
|
||||||
|
|
||||||
public static float Distance(this Vector2D from, Vector2D to) => Vector2D.Distance(from, to);
|
public static float Distance(this Vector2D from, Vector2D to) => Vector2D.Distance(from, to);
|
||||||
|
|
||||||
|
public static Vector2D Invert(this Vector2D vector) => Vector2D.Invert(vector);
|
||||||
|
public static Vector2D Add(this Vector2D vector, Vector2D vectorToAdd) => Vector2D.Add(vector, vectorToAdd);
|
||||||
|
public static Vector2D Subtract(this Vector2D vector, Vector2D vectorToSubtract) => Vector2D.Subtract(vector, vectorToSubtract);
|
||||||
|
public static Vector2D Multiply(this Vector2D vector, float value) => Vector2D.Multiply(vector, value);
|
||||||
|
public static Vector2D Subdivide(this Vector2D vector, float value) => Vector2D.Subdivide(vector, value);
|
||||||
|
|
||||||
public static Vector2D Reflect(this Vector2D vector, Vector2D normal) => Vector2D.Reflect(vector, normal);
|
public static Vector2D Reflect(this Vector2D vector, Vector2D normal) => Vector2D.Reflect(vector, normal);
|
||||||
public static Vector2D Normalize(this Vector2D vector) => Vector2D.Normalize(vector);
|
public static Vector2D Normalize(this Vector2D vector) => Vector2D.Normalize(vector);
|
||||||
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);
|
||||||
|
|
|
@ -28,6 +28,12 @@ public record Vector2D(float X, float Y)
|
||||||
|
|
||||||
public static float Distance(Vector2D from, Vector2D to) => Length(FromTo(from, to));
|
public static float Distance(Vector2D from, Vector2D to) => Length(FromTo(from, to));
|
||||||
|
|
||||||
|
public static Vector2D Invert(Vector2D vector) => new(0f - vector.X, 0f - vector.Y);
|
||||||
|
public static Vector2D Add(Vector2D left, Vector2D right) => left + right;
|
||||||
|
public static Vector2D Subtract(Vector2D left, Vector2D right) => left - right;
|
||||||
|
public static Vector2D Multiply(Vector2D vector, float value) => vector * value;
|
||||||
|
public static Vector2D Subdivide(Vector2D vector, float value) => vector / value;
|
||||||
|
|
||||||
public static Vector2D Normalize(Vector2D vector) => vector / Length(vector);
|
public static Vector2D Normalize(Vector2D vector) => vector / Length(vector);
|
||||||
public static Vector2D Reflect(Vector2D vector, Vector2D normal) => vector - 2f * Dot(vector, normal) * normal;
|
public static Vector2D Reflect(Vector2D vector, Vector2D normal) => vector - 2f * Dot(vector, normal) * normal;
|
||||||
public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from;
|
public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from;
|
||||||
|
|
Loading…
Reference in New Issue