登录论坛

查看完整版本 : Color Cube Meets Rubik?s Cube - Cleve Moler on Mathematics and Computing


poster
2022-12-10, 12:37
I have made a half dozen blog posts about Rubik's Cube (https://blogs.mathworks.com/cleve/2022/09/05/rubiks-cube-superflips-and-gods-number/) so far this year. And, during the MATLAB Central Mini Hack in October, I resurrected an old code about the Color Cube (https://blogs.mathworks.com/cleve/2022/10/21/an-interactive-version-of-colorcubes/). Now, a combination of the two, Rubik/Color Qube, creates an elegant tool for investigating Matrices in Action.

Contents


Opening (https://www.labfans.com/bbs/#c4ab2cc4-7c62-45b6-b8d6-b58e96dd8c07)
Rubik and Color (https://www.labfans.com/bbs/#3426fb76-f361-4a32-b165-f771bba3fb03)
Color Qube (https://www.labfans.com/bbs/#28b692dc-0d85-4c30-905e-300857741d5c)
Rotations (https://www.labfans.com/bbs/#f9469ecf-8b7e-41d3-8f47-ac23128f5f7d)
n-by-n-by-n (https://www.labfans.com/bbs/#eb4d3e17-82e6-4b1e-b966-c75328d89269)
2-by-2-by-2 (https://www.labfans.com/bbs/#715fe67d-21d9-46c4-a0b5-b2864db8776f)
Software (https://www.labfans.com/bbs/#b23519d3-2aa0-46a3-9160-90f256981b7e)

Opening

Here is the opening screen shot of Rubik/Color Qube, one of the most elaborate MATLAB programs that I have ever written.

http://blogs.mathworks.com/cleve/files/screen_shot1.png

Rubik and Color

There are two modes, rubik and color. In rubik mode, the large cube is formed from 27 identical copies of a single small cubelet. The six cubelet faces have six different colors. Red, white and blue are visible initially. Orange, yellow and green become visible as the faces are rotated.

http://blogs.mathworks.com/cleve/files/rubik.gif

In color mode, the large cube is formed from 27 cubelets, each with a different solid color. Three of the corner cubelets are the primary colors in the RGB color model -- red, green and blue. Three more corners are the complementary cyan, magenta and yellow. White and black complete the list of corners.

http://blogs.mathworks.com/cleve/files/color.gif

Color Qube

All of the familiar Rubik's moves are available in color mode. Here is a screen shot after a few rotations.

http://blogs.mathworks.com/cleve/files/screen_shot2.png

Rotations

Rotation matrices defined by this Rk function are the basic mathematical tool employed by Qube. The animation provides a detailed look at the action produced by the F key, counter-clockwise rotation of the Front face. This is the y-axis, case 2 in Rk. The detail is provided by taking d = 0:3:90, so there are 30 steps of 3 degrees.

function R = Rk(axis,d) % Rk(axis,d), Rotation by d degrees about the x-, y-, or z-axis. c = cosd(d); s = sind(d); switch axis case 1, R = [ 1 0 0 0 c s 0 -s c ]; case 2, R = [ c 0 s 0 1 0 -s 0 c ]; case 3, R = [ c s 0 -s c 0 0 0 1 ]; end fmat = findobj('tag','fmat'); if ~isempty(fmat) fmat.String = mat3(R); endendhttp://blogs.mathworks.com/cleve/files/dpm3.gif

n-by-n-by-n

Qube generalizes the classic 3-by-3-by-3 Rubik's Cube to n-by-n-by-n cubes for any n.

http://blogs.mathworks.com/cleve/files/n_by_n.gif

2-by-2-by-2

The 2-by-2-by-2 cubes are good starting points for investigation of mathematical properties.

http://blogs.mathworks.com/cleve/files/2_by_2.png

http://blogs.mathworks.com/cleve/files/2_by_2_color.png

Software

Qube is available as a self-extracting MATLAB archive at this link, Qube_mzip.m (https://blogs.mathworks.com/cleve/files/Qube_mzip.m).


Get the MATLAB code (requires JavaScript) (javascript:grabCode_ce9c453c88254608ad0e691ca4711df7())

Published with MATLAB® R2022b





More... (https://blogs.mathworks.com/cleve/2022/12/09/color-cube-meets-rubiks-cube/?s_tid=feedtopost)