fixed Vector2Int Distance issue
This commit is contained in:
parent
dfb5a5af40
commit
f479cfc8fa
@ -1,6 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Passer.LinearAlgebra {
|
namespace Passer.LinearAlgebra {
|
||||||
|
|
||||||
public class Vector2Of<T> {
|
public class Vector2Of<T> where T : IComparable<T> {
|
||||||
public T x;
|
public T x;
|
||||||
public T y;
|
public T y;
|
||||||
|
|
||||||
@ -12,8 +15,37 @@ namespace Passer.LinearAlgebra {
|
|||||||
|
|
||||||
public class Vector2Int : Vector2Of<int> {
|
public class Vector2Int : Vector2Of<int> {
|
||||||
public Vector2Int(int x, int y) : base(x, y) { }
|
public Vector2Int(int x, int y) : base(x, y) { }
|
||||||
|
|
||||||
|
public static Vector2Int operator -(Vector2Int v1, Vector2Int v2) {
|
||||||
|
return new Vector2Int(v1.x - v2.x, v1.y - v2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float magnitude {
|
||||||
|
get {
|
||||||
|
return (float)Math.Sqrt(this.x * this.x + this.y * this.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float Distance(Vector2Int v1, Vector2Int v2) {
|
||||||
|
return (v1 - v2).magnitude;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Vector2Float : Vector2Of<float> {
|
public class Vector2Float : Vector2Of<float> {
|
||||||
public Vector2Float(float x, float y) : base(x, y) { }
|
public Vector2Float(float x, float y) : base(x, y) { }
|
||||||
|
|
||||||
|
public static Vector2Float operator -(Vector2Float v1, Vector2Float v2) {
|
||||||
|
return new Vector2Float(v1.x - v2.x, v1.y - v2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float magnitude {
|
||||||
|
get {
|
||||||
|
return (float)Math.Sqrt(this.x * this.x + this.y * this.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float Distance(Vector2Float v1, Vector2Float v2) {
|
||||||
|
return (v1 - v2).magnitude;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user