Exemplo n.º 1
0
        public static int M8By8FloatOffset(this int lhs, double xOff, double yOff)
        {
            var typed = new _M8By8(lhs);

            var valueX = (typed.ValueX.M8ToDouble() + xOff).AsM8();
            var valueY = (typed.ValueY.M8ToDouble() + yOff).AsM8();

            return (valueX << Bits) + valueY;
        }
Exemplo n.º 2
0
 public static int[] ToCornersOnM8By8(this int index)
 {
     var typed = new _M8By8(index);
     var upLeft = new _M8By8((typed.ValueX - 1).AsM8(), (typed.ValueY - 1).AsM8());
     var upRight = new _M8By8((typed.ValueX + 1).AsM8(), (typed.ValueY - 1).AsM8());
     var lowLeft = new _M8By8((typed.ValueX - 1).AsM8(), (typed.ValueY + 1).AsM8());
     var lowRight = new _M8By8((typed.ValueX + 1).AsM8(), (typed.ValueY + 1).AsM8());
     return new[] { upLeft.Index, upRight.Index, lowLeft.Index, lowRight.Index };
 }
Exemplo n.º 3
0
 public static int[] ToSidesOnM8By8(this int index)
 {
     var typed = new _M8By8(index);
     var top = new _M8By8(typed.ValueX, typed.ValueY - 1);
     var right = new _M8By8(typed.ValueX + 1, typed.ValueY);
     var bottom = new _M8By8(typed.ValueX, typed.ValueY + 1);
     var left = new _M8By8(typed.ValueX - 1, typed.ValueY);
     return new[] { top.Index, right.Index, bottom.Index, left.Index };
 }
Exemplo n.º 4
0
        public static int[] ToPerimeterOnM8By8(this int index)
        {
            var typed = new _M8By8(index);
            var top = new _M8By8(typed.ValueX, typed.ValueY - 1);
            var right = new _M8By8(typed.ValueX + 1, typed.ValueY);
            var bottom = new _M8By8(typed.ValueX, typed.ValueY + 1);
            var left = new _M8By8(typed.ValueX - 1, typed.ValueY);
            var upLeft = new _M8By8((typed.ValueX - 1).AsM8(), (typed.ValueY - 1).AsM8());
            var upRight = new _M8By8((typed.ValueX + 1).AsM8(), (typed.ValueY - 1).AsM8());
            var lowLeft = new _M8By8((typed.ValueX - 1).AsM8(), (typed.ValueY + 1).AsM8());
            var lowRight = new _M8By8((typed.ValueX + 1).AsM8(), (typed.ValueY + 1).AsM8());

            return new[] { top.Index, right.Index, bottom.Index, left.Index, upLeft.Index, upRight.Index, lowLeft.Index, lowRight.Index };
        }
Exemplo n.º 5
0
        static void MakeForceField()
        {
            forceField[0] = new[] { 0.0f, 0.0f, 0.0f };

            for (var i = 1; i < Mod; i++)
            {
                var typed = new _M8By8(i);
                var distance = Math.Sqrt(typed.ValueX.M8ToDouble() * typed.ValueX.M8ToDouble() + typed.ValueY.M8ToDouble() * typed.ValueY.M8ToDouble());
                forceField[i] = new[] { (float)distance, (float)(typed.ValueX.M8ToDouble() / distance), (float)(typed.ValueY.M8ToDouble() / distance) };
            }
        }