/// <summary> /// Gives a coloring of the grid such that /// if a point p has color k, then all points /// p + m[ux, 0] + n[vx, vy] have the same color /// for any integers a and b. /// /// More information anout grid colorings: /// http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/ /// /// Since version 1.7 /// </summary> public int __GetColor__ReferenceImplementation(int ux, int vx, int vy) { var u = new RectPoint(ux, 0); var v = new RectPoint(vx, vy); int colorCount = u.PerpDot(v); float a = PerpDot(v) / (float)colorCount; float b = -PerpDot(u) / (float)colorCount; int m = Mathf.FloorToInt(a); int n = Mathf.FloorToInt(b); int baseVectorX = m * u.X + n * v.X; int baseVectorY = n * u.Y + n * v.Y; int offsetX = GLMathf.FloorMod(X - baseVectorX, ux); int offsetY = Y - baseVectorY; int colorIndex = Mathf.FloorToInt(offsetX + offsetY * ux); return(colorIndex); }