It sounds like you might like my answer here: http://programmers.stackexchange.com/a/262847/156217https://softwareengineering.stackexchange.com/a/262847/156217
The basic idea is:
- Address the cube in an x-y-z coordinate system, with a center at (0, 0, 0).
- A Piece class stores a position
(x, y, z) and colors(cx, cy, cz). The Piece knows which sticker colors are on which axis (x, y, or z) but doesn't know which direction the sticker is facing. - The Cube stores an unordered list of Pieces.
- Rotations are done by updating the position and colors of the relevant Pieces.
This is nice because all rotation logic is confined to the Piece class. A Piece doesn't know its orientation, but it doesn't need to. The orientation of a Piece is strictly dependent on its position: the corner at (-1, -1, -1) is the LEFT-UP-BACK corner.