public static int[] ToCornersOnM10By10(this int index) { var typed = new _M10By10(index); var upLeft = new _M10By10((typed.ValueX - 1).AsM10(), (typed.ValueY - 1).AsM10()); var upRight = new _M10By10((typed.ValueX + 1).AsM10(), (typed.ValueY - 1).AsM10()); var lowLeft = new _M10By10((typed.ValueX - 1).AsM10(), (typed.ValueY + 1).AsM10()); var lowRight = new _M10By10((typed.ValueX + 1).AsM10(), (typed.ValueY + 1).AsM10()); return new[] { upLeft.Index, upRight.Index, lowLeft.Index, lowRight.Index }; }
public static int M10By10FloatOffset(this int lhs, double xOff, double yOff) { var typed = new _M10By10(lhs); var valueX = (typed.ValueX.M10ToDouble() + xOff).AsM10(); var valueY = (typed.ValueY.M10ToDouble() + yOff).AsM10(); return (valueX << Bits) + valueY; }
public static int[] ToPerimeterOnM10By10(this int index) { var typed = new _M10By10(index); var top = new _M10By10(typed.ValueX, typed.ValueY - 1); var right = new _M10By10(typed.ValueX + 1, typed.ValueY); var bottom = new _M10By10(typed.ValueX, typed.ValueY + 1); var left = new _M10By10(typed.ValueX - 1, typed.ValueY); var upLeft = new _M10By10((typed.ValueX - 1).AsM10(), (typed.ValueY - 1).AsM10()); var upRight = new _M10By10((typed.ValueX + 1).AsM10(), (typed.ValueY - 1).AsM10()); var lowLeft = new _M10By10((typed.ValueX - 1).AsM10(), (typed.ValueY + 1).AsM10()); var lowRight = new _M10By10((typed.ValueX + 1).AsM10(), (typed.ValueY + 1).AsM10()); return new[] { top.Index, right.Index, bottom.Index, left.Index, upLeft.Index, upRight.Index, lowLeft.Index, lowRight.Index }; }
static void MakeForceField() { forceField[0] = new[] { 0.0f, 0.0f, 0.0f }; for (var i = 1; i < Mod; i++) { var typed = new _M10By10(i); var distance = Math.Sqrt(typed.ValueX.M10ToDouble() * typed.ValueX.M10ToDouble() + typed.ValueY.M10ToDouble() * typed.ValueY.M10ToDouble()); forceField[i] = new[] { (float)distance, (float)(typed.ValueX.M10ToDouble() / distance), (float)(typed.ValueY.M10ToDouble() / distance) }; } }
public static int[] ToSidesOnM10By10(this int index) { var typed = new _M10By10(index); var top = new _M10By10(typed.ValueX, typed.ValueY - 1); var right = new _M10By10(typed.ValueX + 1, typed.ValueY); var bottom = new _M10By10(typed.ValueX, typed.ValueY + 1); var left = new _M10By10(typed.ValueX - 1, typed.ValueY); return new[] { top.Index, right.Index, bottom.Index, left.Index }; }