PyCube is an 3D interactive Rubik's Cube using OpenGL and Pygame. Quaternions are used to rotate the 3D plane and rotation matrices to rotate the pieces.
This software-based Rubik's Cube will serve as a basis for a later project in which I will attempt to create another program, implementing a neural network algorithm, that will teach itself to solve a Rubik's Cube (PyCube).
This program utilizes the following Python modules:
PyOpenGL
see also OpenGL
Pygame
NumPy
pip3 install pyopengl pygame numpy
pip install pyopengl pygame numpy
This post from stackoverflow was very helpful in creating a solid starting point to use quaternions to rotate a 3 dimensional cube using Python and OpenGL.
by Michael
Posted
So the cube itself is nearing completion. I have implemented the corner pieces and applied the appropriate algorithm in order to make them rotate correctly, as well as colored them. I also adjusted the appearance a bit. I spaced out the pieces to give a more realistic look. I put a sphere in the center to symbolize the central spherical gear that's used in an actual Rubik's Cube (the newer versions). Lastly I experimented with an exploded view that separates the pieces and exposed the inside of the cube. From here I'm going to begin work on a 'reverse moves' solver.
by Michael
Posted
I'm swiftly making significant progress. I have implemented all of the edge pieces and have also been able to make them rotate correctly with an algorithm that utilizes the rotation matrices. Correctly coloring each of the edge pieces and 'stickers' was an unforeseen challenge, but luckily I was able to tackle that one. Now I will continue on to implement the corner pieces which shouldn't be too hard considering they won't be much different from the edge pieces.
by Michael
Posted
So over the summer I shelved PyCube until I started looking into graphics with OpenGL. Seeing how the graphics can be so much better compared to VPython I decided to revisit PyCube and rebuild it from the ground up using PyOpenGL, Pygame, NumPy, lots of quaternions, matrix math, and vector management. I think I'm off to a good start. I have a semi-working Rubik's cube with only the center pieces. You use the FBLRUD keys to rotate the faces. Lowercase for CW and [Shift] for CCW. Oh, and you can click and drag with the mouse to move the cube around (can also use arrow keys) as well as zoom in and out with the mouse wheel. I'm happy with the result but there is still a lot more work to be done.
PyCube is an 3D interactive Rubik's Cube using OpenGL and Pygame. Quaternions are used to rotate the 3D plane and rotation matrices to rotate the pieces.
This software-based Rubik's Cube will serve as a basis for a later project in which I will attempt to create another program, implementing a neural network algorithm, that will teach itself to solve a Rubik's Cube (PyCube).
This program utilizes the following Python modules:
PyOpenGL
see also OpenGL
Pygame
NumPy
pip3 install pyopengl pygame numpy
pip install pyopengl pygame numpy
This post from stackoverflow was very helpful in creating a solid starting point to use quaternions to rotate a 3 dimensional cube using Python and OpenGL.