feat: Vector2D.Scale Method
This commit is contained in:
parent
063473e0b5
commit
661f2027ce
|
@ -16,6 +16,7 @@ public record Vector2D(float X, float Y)
|
||||||
|
|
||||||
public static Vector2D Normalize(Vector2D vector) => vector / Length(vector);
|
public static Vector2D Normalize(Vector2D vector) => vector / Length(vector);
|
||||||
public static Vector2D FromTo(Vector2D from, Vector2D to) => to - from;
|
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);
|
||||||
|
|
||||||
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)));
|
||||||
|
|
|
@ -4,10 +4,11 @@ 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.LengthSquared(vector);
|
public static float Distance(this Vector2D from, Vector2D to) => Vector2D.Distance(from, to);
|
||||||
|
|
||||||
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);
|
||||||
|
public static Vector2D Scale(this Vector2D vector, Vector2D scale) => Vector2D.FromTo(vector, scale);
|
||||||
|
|
||||||
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