Exemplo n.º 1
0
        private static (int, int) EncodeAxisAndDelta(CoordDiff diff, int correction)
        {
            var nonZeroSum = (diff.Dx != 0 ? 1 : 0) + (diff.Dy != 0 ? 1 : 0) + (diff.Dz != 0 ? 1 : 0);

            if (nonZeroSum != 1)
            {
                throw new ArgumentOutOfRangeException(string.Format("Exactly one non-zero component expected: {0}", diff));
            }

            int shift;
            int axis;

            if (diff.Dx != 0)
            {
                shift = diff.Dx;
                axis  = Constants.XAxis;
            }
            else if (diff.Dy != 0)
            {
                shift = diff.Dy;
                axis  = Constants.YAxis;
            }
            else
            {
                shift = diff.Dz;
                axis  = Constants.ZAxis;
            }

            if (Math.Abs(shift) > correction)
            {
                throw new ArgumentOutOfRangeException(string.Format("The diff component is too large: {0}", shift));
            }

            return(axis, shift + correction);
        }
Exemplo n.º 2
0
        private static int EncodeNearDiff(CoordDiff diff)
        {
            var cl = diff.CLen();
            var ml = diff.MLen();

            if (cl != 1 || (ml <= 0 || ml > 2))
            {
                throw new ArgumentOutOfRangeException(string.Format("Invalid near diff: {0}", diff));
            }
            return(((diff.Dx + 1) * 9 + (diff.Dy + 1) * 3 + (diff.Dz + 1)) << 3);
        }
Exemplo n.º 3
0
 public void Apply(CoordDiff diff)
 {
     X += diff.Dx;
     Y += diff.Dy;
     Z += diff.Dz;
 }
Exemplo n.º 4
0
 public Fill(int dx, int dy, int dz)
 {
     Diff = new CoordDiff(dx, dy, dz);
 }
Exemplo n.º 5
0
 public Fission(int dx, int dy, int dz, int m)
 {
     Diff = new CoordDiff(dx, dy, dz);
     M    = m;
 }