feat: Vector2D.Reflect
This commit is contained in:
parent
a03470d043
commit
0519adfcce
|
@ -23,6 +23,7 @@ public record Vector2D(float X, float Y)
|
|||
public static float Distance(Vector2D from, Vector2D to) => Length(FromTo(from, to));
|
||||
|
||||
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 FromTo(Vector2D from, Vector2D to) => to - from;
|
||||
public static Vector2D Scale(Vector2D vector, Vector2D scale) => new(vector.X * scale.X, vector.Y * scale.Y);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ public static class Vector2DExtensions
|
|||
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 Vector2D Reflect(this Vector2D vector, Vector2D normal) => Vector2D.Reflect(vector, normal);
|
||||
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 Scale(this Vector2D vector, Vector2D scale) => Vector2D.FromTo(vector, scale);
|
||||
|
|
Loading…
Reference in New Issue