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); }
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); }
public void Apply(CoordDiff diff) { X += diff.Dx; Y += diff.Dy; Z += diff.Dz; }
public Fill(int dx, int dy, int dz) { Diff = new CoordDiff(dx, dy, dz); }
public Fission(int dx, int dy, int dz, int m) { Diff = new CoordDiff(dx, dy, dz); M = m; }