[swCube.m] Function for Rubik Cube Operations

Input operation sequence under the rules [rcOpNames.m]. Output a figure with operations on Rubik cube step by step.
11 téléchargements
Mise à jour 24 juin 2024

Afficher la licence

About operations on Rubik cube
The function [swCube.m] presents the operations on Rubik cube step by step. Some details may as follows:
The Rubik cube contains 27 small cubes, and we numbering each of them by like above (see the picture on the left). We call six sides of the Rubik cube as [Down, Left, Front, Right, Back, Upper] side, respectively, and denote them by for simplicity. And we paint all sides with default colors [Prussian blue, Dark orange, Medium yellow, Purple, Pine green, Light sky blue] (see the GIF on the right).
Step A. Numbering permutation
For each opration, find out the numberings and the numbering permutation for a specific 9 small cubes. For example, for the operation , the numbering permutation is .
Step B. Color permutation
Find out the colors permutation of each small cube for the operation. For example, for the operation , the color permutation is .
Step C. Variational color scheme
In fact, the color information of all 27 small cubes maps uniquely to a state of the Rubik cube. We use a matrix to denote the color scheme in the step n, of which the elements belong to . The color scheme will be updated by the following formula: , where represents the permutation matrix of , which satisfies that .
>> swCube(0)
% Please wait for initiating ...
% >> sw: (0) Please input the operation sequence (or try 'swOseq_k'):
OE-PM-PE-OM
% (0) Your input is swOp(6) 'F6_Six O-Letter', which includes 4 steps.
% (0) Do you want to save the figure as .png file? [y/n]
y
% (0) Do you want to play again? [y/n] Start with an inintial state? [y1]
y1
% >> sw: (1) Please set up the initial state (or try 'swOseq_k'):
OL-OM-OR
% (1) Your input is swOp(-1) 'OL-OM-OR', which includes 3 steps.
% >> sw: (1) Please input the operation sequence (or try 'swOseq_k'):
PF-R2-U2-R2-OF-PB-U2-OL-PF-OB-L2-OD-OR-OL-OD-OU-PL-PB-PL-PM-PR
% (1) Your input is swOp(-1) 'PF-R2-U2-R2-OF-PB-U2-OL-PF-OB-L2-OD-OR-OL-OD-OU-PL-PB-PL-PM-PR', which includes 21 steps.
% (1) Do you want to save the figure as .png file? [y/n]
y
% (1) Do you want to play again? [y/n] Start with an inintial state? [y1]
n
Documentation
  • swCube(Tp) %sw: Present each step of operation in a figure, and pause 'Tp' second for each step (default 'Tp=0.2');
  • swRView(vT) %sw: 3D rotating view of the Rubik cube, with viewing time 'vT' (default 'vT=10');
  • rcOpNames %sw: A table of standard operation names, with a picture on the numberings of the Rubik cube;
  • rcOpM(Oseq,strV) %sw: Translate an operation sequence under a new view;
  • rcOpInv(Oseq) %sw: Output the inverse of an operation sequence;
>> swRView
% >> sw: Do you want to save 3D rotating view as .gif file? [y/n]
y
% >> Please input a suffix name for *.gif:
Superflip(1995)

Citation pour cette source

Swank Williams (2024). [swCube.m] Function for Rubik Cube Operations (https://www.mathworks.com/matlabcentral/fileexchange/154306-swcube-m-function-for-rubik-cube-operations), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2023b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0.2

[1.0.2] Second revised version: Main function has been updated, with changing "[D,R,B,L,F,U]" to "[D,L,F,R,B,U]", adding "D2,E2,..." to the operation names, and adding new functions [rcOpNames.m], [rcOpM.m], [rcOpInv.m].

1.0.1

[1.0.0] Version for publication;
[1.0.1] First revised version: add filefolder 'SavePNG'/ update C_NameRules.m and swRView.m

1.0.0