![]() |
Color Cube Meets Rubik?s Cube - Cleve Moler on Mathematics and Computing
I have made a half dozen blog posts about [URL="https://blogs.mathworks.com/cleve/2022/09/05/rubiks-cube-superflips-and-gods-number/"]Rubik's Cube[/URL] so far this year. And, during the MATLAB Central Mini Hack in October, I resurrected an old code about the [URL="https://blogs.mathworks.com/cleve/2022/10/21/an-interactive-version-of-colorcubes/"]Color Cube[/URL]. Now, a combination of the two, Rubik/Color Qube, creates an elegant tool for investigating [I]Matrices in Action[/I].
[B]Contents[/B] [LIST][*][URL="https://www.labfans.com/bbs/#c4ab2cc4-7c62-45b6-b8d6-b58e96dd8c07"]Opening[/URL][*][URL="https://www.labfans.com/bbs/#3426fb76-f361-4a32-b165-f771bba3fb03"]Rubik and Color[/URL][*][URL="https://www.labfans.com/bbs/#28b692dc-0d85-4c30-905e-300857741d5c"]Color Qube[/URL][*][URL="https://www.labfans.com/bbs/#f9469ecf-8b7e-41d3-8f47-ac23128f5f7d"]Rotations[/URL][*][URL="https://www.labfans.com/bbs/#eb4d3e17-82e6-4b1e-b966-c75328d89269"]n-by-n-by-n[/URL][*][URL="https://www.labfans.com/bbs/#715fe67d-21d9-46c4-a0b5-b2864db8776f"]2-by-2-by-2[/URL][*][URL="https://www.labfans.com/bbs/#b23519d3-2aa0-46a3-9160-90f256981b7e"]Software[/URL][/LIST][B]Opening[/B] Here is the opening screen shot of Rubik/Color Qube, one of the most elaborate MATLAB programs that I have ever written. [IMG]http://blogs.mathworks.com/cleve/files/screen_shot1.png[/IMG] [B]Rubik and Color[/B] There are two modes, rubik and color. In rubik mode, the large cube is formed from 27 identical copies of a single small [I]cubelet[/I]. 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. [IMG]http://blogs.mathworks.com/cleve/files/rubik.gif[/IMG] In color mode, the large cube is formed from 27 [I]cubelets[/I], 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. [IMG]http://blogs.mathworks.com/cleve/files/color.gif[/IMG] [B]Color Qube[/B] All of the familiar Rubik's moves are available in color mode. Here is a screen shot after a few rotations. [IMG]http://blogs.mathworks.com/cleve/files/screen_shot2.png[/IMG] [B]Rotations[/B] 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); endend[IMG]http://blogs.mathworks.com/cleve/files/dpm3.gif[/IMG] [B]n-by-n-by-n[/B] Qube generalizes the classic 3-by-3-by-3 Rubik's Cube to n-by-n-by-n cubes for any n. [IMG]http://blogs.mathworks.com/cleve/files/n_by_n.gif[/IMG] [B]2-by-2-by-2[/B] The 2-by-2-by-2 cubes are good starting points for investigation of mathematical properties. [IMG]http://blogs.mathworks.com/cleve/files/2_by_2.png[/IMG] [IMG]http://blogs.mathworks.com/cleve/files/2_by_2_color.png[/IMG] [B]Software[/B] Qube is available as a self-extracting MATLAB archive at this link, [URL="https://blogs.mathworks.com/cleve/files/Qube_mzip.m"]Qube_mzip.m[/URL]. [RIGHT][COLOR=gray][I] [URL="javascript:grabCode_ce9c453c88254608ad0e691ca4711df7()"][I]Get the MATLAB code (requires JavaScript)[/I][/URL] Published with MATLAB® R2022b [/I][/COLOR][/RIGHT] [url=https://blogs.mathworks.com/cleve/2022/12/09/color-cube-meets-rubiks-cube/?s_tid=feedtopost]More...[/url] |
所有时间均为北京时间。现在的时间是 04:55。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.