i have created 27 cubes using opengl and c++ and assembled for rubicks cube but not able to write rotate function for a slice.how to do????

8 Years
Discussion Span
Last Post by Lerner

Try to convince JTC1/SC22/WG21 (The C++ Standards Committee) to incude class RubiksCube into the next (or better in the current) C++ Standard. After that you may expect to get the answer to simple and clear questions like that ;)
See also: http://en.wikipedia.org/wiki/Rubik's_cube#Algorithms


What I've seen done is to create a class to represent a single Rubik's cube that consists of an array of 27 minicubes and 6 layers called top, bottom, middle, right, left, center. Each move consists of the twist of one layer at a time relative to the other two in either the vertical or horizontal gruop of layers and results in shifts in the positions of the minicubes involved in the twist within the array of minicubes, unless you rotate the whole cube. That logic is completely separate from the "graphics display of the process" using your graphics package. IMO, having a cube in front of you when trying to develop the logic of the changes within the array with each twist is essential.

When you get to the graphics part, which is the "fun stuff" I guess, I would recommend doing a stepwise approach by figuring out how to twist a single minicube by itself in any direction you want, and then how to twist two minicubes simultaneously before generalizing it to twisting a single layer relative to other layers.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.