bottom static method

int bottom(
  1. Box cube,
  2. Direction direction,
  3. List<int> moment
)

Implementation

static int bottom(Box cube, Direction direction, List<int> moment) {
  switch (direction) {
    case Direction.red:
      return -moment[getIndex(cube.r0, cube.g1, cube.b1)] +
          moment[getIndex(cube.r0, cube.g1, cube.b0)] +
          moment[getIndex(cube.r0, cube.g0, cube.b1)] -
          moment[getIndex(cube.r0, cube.g0, cube.b0)];
    case Direction.green:
      return -moment[getIndex(cube.r1, cube.g0, cube.b1)] +
          moment[getIndex(cube.r1, cube.g0, cube.b0)] +
          moment[getIndex(cube.r0, cube.g0, cube.b1)] -
          moment[getIndex(cube.r0, cube.g0, cube.b0)];
    case Direction.blue:
      return -moment[getIndex(cube.r1, cube.g1, cube.b0)] +
          moment[getIndex(cube.r1, cube.g0, cube.b0)] +
          moment[getIndex(cube.r0, cube.g1, cube.b0)] -
          moment[getIndex(cube.r0, cube.g0, cube.b0)];
    default:
      throw 'unexpected direction $direction';
  }
}