using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; namespace StgSharp.Math { [StructLayout(LayoutKind.Explicit)] public struct Colum2D:IEquatable { [FieldOffset(0)] public float X; [FieldOffset(4)] public float Y; public Colum2D(float x,float y) { X= x; Y= y; } public override bool Equals(object obj) { if (obj == null) { return false; } else if (obj.GetType() != typeof(Colum2D)) { return false; } else { return this.Equals((Colum2D)obj); } } bool IEquatable.Equals(Colum2D other) { if (this.GetHashCode() != other.GetHashCode()) { return false; } else { return X == other.X && Y == other.Y; } } public override int GetHashCode() { return HashCode.Combine(X,Y); } public override string ToString() { return $"{X}\n{Y}"; } public static Colum2D operator +(Colum2D c1,Colum2D c2) { return new Colum2D( c1.X + c2.X, c1.Y + c2.Y ); } public static Colum2D operator -(Colum2D c1, Colum2D c2) { return new Colum2D( c1.X - c2.X, c1.Y - c2.Y ); } public static Colum2D operator *(Colum2D colum, float x) { return new Colum2D(colum.X * x,colum.Y * x); } public static Colum2D operator /(Colum2D colum, float x) { return new Colum2D(colum.X / x, colum.Y / x); } } }