void Piece::RotateXCCW() { isMoved = true; unsigned int n = size; unsigned int colLimit = floor((float) n / 2.0); unsigned int rowLimit = ceil((float) n / 2.0); for (unsigned int c = 0; c < n; c++) { for (unsigned int d = 0; d < colLimit; d++) { for (unsigned int r = 0; r < rowLimit; r++) { Voxel* temp = container[c][r][d]; if (temp != 0) { temp = temp->Copy(); } //SwapVoxels(c, r, d, container[n - 1 - r][c][d]); SwapVoxels(c, r, d, container[c][d][n - 1 - r]); //SwapVoxels(n - 1 - r, c, d, container[n - 1 - c][n - 1 - r][d]); SwapVoxels(c, d, n - 1 - r, container[c][n - 1 - r][n - 1 - d]); //SwapVoxels(n - 1 - c, n - 1 - r, d, container[r][n - 1 - c][d]); SwapVoxels(c, n - 1 - r, n - 1 - d, container[c][n - 1 - d][r]); //SwapVoxels(r, n - 1 - c, d, temp); SwapVoxels(c, n - 1 - d, r, temp); } } } }
void Piece::RotateZCCW() { isMoved = true; unsigned int n = size; unsigned int colLimit = floor((float) n / 2.0); unsigned int rowLimit = ceil((float) n / 2.0); // unsigned int topRow = GetTopRow(); // unsigned int leftCol = GetLeftCol(); // unsigned int topDep = GetTopDep(); for (unsigned int d = 0; d < size; d++) { for (unsigned int c = 0; c < colLimit; c++) { for (unsigned int r = 0; r < rowLimit; r++) { Voxel* temp = container[c][r][d]; if (temp != 0) { temp = temp->Copy(); } SwapVoxels(c, r, d, container[n - 1 - r][c][d]); // container[c][r][d] = container[n - 1 - r][c][d]; SwapVoxels(n - 1 - r, c, d, container[n - 1 - c][n - 1 - r][d]); //container[n - 1 - r][c][d] = container[n - 1 - c][n - 1 - r][d]; SwapVoxels(n - 1 - c, n - 1 - r, d, container[r][n - 1 - c][d]); // container[n - 1 - c][n - 1 - r][d] = container[r][n - 1 - c][d]; SwapVoxels(r, n - 1 - c, d, temp); //container[r][n - 1 - c][d] = temp; } } } }