using System; namespace Orvid.Graphics { /// /// This is a 2d vector. aka. A point on a 2d plane. /// public struct Vec2 { /// /// The X position. /// public int X; /// /// The Y position. /// public int Y; /// /// The default constructor. /// /// The X position. /// The Y position. public Vec2(int x, int y) { this.X = x; this.Y = y; } /// /// /// /// /// public static Vec2 operator -(Vec2 v) { Vec2 vec = new Vec2(); vec.X = -v.X; vec.Y = -v.Y; return vec; } /// /// /// /// /// /// public static Vec2 operator -(Vec2 a, Vec2 b) { Vec2 v; v.X = a.X - b.X; v.Y = a.Y - b.Y; return v; } /// /// /// /// /// /// public static Vec2 operator +(Vec2 a, Vec2 b) { Vec2 v; v.X = a.X + b.X; v.Y = a.Y + b.Y; return v; } /// /// /// /// /// /// public static Vec2 operator /(Vec2 a, Vec2 b) { Vec2 v; v.X = a.X / b.X; v.Y = a.Y / b.Y; return v; } /// /// /// /// /// /// public static Vec2 operator /(Vec2 a, int b) { Vec2 v; v.X = (Int32)(a.X / b); v.Y = (Int32)(a.Y / b); return v; } /// /// /// /// /// /// public static Vec2 operator /(Vec2 v, float s) { Vec2 vec; float num = 1f / s; vec.X = (Int32)(v.X * num); vec.Y = (Int32)(v.Y * num); return vec; } /// /// /// /// /// /// public static Vec2 operator /(float s, Vec2 v) { Vec2 vec; vec.X = (Int32)(s / v.X); vec.Y = (Int32)(s / v.Y); return vec; } /// /// /// /// /// /// public static bool operator !=(Vec2 a, Vec2 b) { if (a.X != b.X || a.Y != b.Y) return true; return false; } /// /// /// /// /// /// public static bool operator ==(Vec2 a, Vec2 b) { if (a.X != b.X || a.Y != b.Y) return false; return true; } /// /// /// /// /// public override bool Equals(object obj) { return (this == (Vec2)obj); } /// /// /// /// public override int GetHashCode() { return base.GetHashCode(); } } }