using UnityEngine; namespace Metamesh { public class IsoVector { public int x; public int y; public IsoVector(int x, int y) { this.x = x; this.y = y; } public IsoVector Clone() { return new IsoVector(x, y); } public IsoVector Rotate60About(IsoVector other) { var x = this.x; this.x = other.x + other.y - this.y; this.y = x + this.y - other.x; return this; } public IsoVector RotateNeg60About(IsoVector other) { var x = this.x; this.x = x + this.y - other.y; this.y = other.x + other.y - x; return this; } public IsoVector Rotate120(int m, int n) { var x = this.x; this.x = m - x - this.y; this.y = n + x; return this; } public IsoVector RotateNeg120(int m, int n) { var x = this.x; this.x = this.y - n; this.y = m + n - x - this.y; return this; } public Vector3 ToCartesianOrigin(IsoVector origin, float isoGridSize) { var point = Vector3.zero; point.x = origin.x + 2 * this.x * isoGridSize + this.y * isoGridSize; point.y = origin.y + Mathf.Sqrt(3) * this.y * isoGridSize; return point; } public static IsoVector Zero() { return new IsoVector(0, 0); } } }