Cleve的角落:数学和计算上的Clyver

科学计算,数学和更多

Digital Simulation of Rubik’s Cube

Rubik's Cube is one of the great mathematical puzzles of all time. Most people are just interested in solving Rubik's Cube rapidly, but deeper investigation reveals a rich mathematical and computational structure. A digital Rubik's Cube simulator provides a laboratory for the study of linear algebra, group theory, data structures and computer graphics.

内容

Cubelets.

我们的抽象魔方的立方体由我称之为的小立方体的27个相同的副本制成cubelet.。在下面的第一个视图中,您可以看到三个传统颜色的Cubelet面孔 - 绿色,白色和橙色。旋转立方体,你看到白脸对面的脸部是黄色的,橙色面孔的面孔是红色的。围绕不同轴的旋转将揭示绿色面孔对面的脸部是蓝色的。

cubelet.

Four types

An ingenious spring mechanism holds an actual physical Rubik's Cube together while allowing rotation of its faces. On the other hand, our computer model of the puzzle does not involve any springs and its faces are rotated by 3-by-3 matrices.

The 27 cubelets in the model have four types -- center, face, edge and corner. The center cubelet is never visible and rotates only when the viewpoint of the entire puzzle is rotated.

There are six cubelets at the centers of the six puzzle faces. They rotate when the corresponding puzzle face is rotated.

There are twelve cubelets in the middle of the twelve puzzle edges. Each edge cubelet shows two colors from its associated faces, green-white, white-orange and so on. There is no orange-red edge cube because the orange and red faces of the puzzle never share a common edge.

有八个角块,每个角落都显示三种颜色,绿色橙色,绿橙色黄色,等等。在6x5x4 = 120可能的六种颜色组合,角隅棱镜只需要八个。

以下是如果您从中中心加上六个脸部Cubelets,则会发生什么,然后添加十二个边缘立方体,最后添加八个角码。

show_types.

Q0

我将使用大写字母Q表示立方体。立方体是一个3×3×3个单元格阵列。每个单元格包含Cubelet的顶点,存储在加倍的8×3矩阵中。这是总共27个顶点矩阵,每个顶点矩阵可以乘以旋转。将相同的旋转应用于立方体中的所有27个立方体旋转整个立方体。将给定旋转应用于其中一个立方体面的9个立方体来说更有趣,同时将其他18个立方体保持不变。

我会使用Q0表示具有相同颜色的脸部中具有所有立方体的拼图。

Qfigure Qshow(Q0)

Code

The code for generatingQ0begins with a matrixv包含中心Cubelet的顶点,qzero

typeqzero
function q0 = qzero % Unit cubelet. q0 = [-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1]; end

With loop variablesx,yzthat take on all possible combinations of-2,0+2,内心的陈述涉及数量

v + [x y z]

这是矩阵和矢量的总和,其未在传统的线性代数中定义。Matlab Singleton扩展将其重写为两个矩阵的总和。所以,x,yz是Cubelet中心的坐标,输出单元阵列具有所有立方体的顶点Q0

typeQ0。m
function Q = Q0(w) if nargin < 1 w = width; end v = w*qzero; Q = cell(3,3,3); for z = [-2 0 2] for y = [-2 0 2] for x = [-2 0 2] Q{x/2+2,y/2+2,z/2+2} = v + [x y z]; end end end end

David Singmaster

David Singmaster was one of the first mathematicians to investigate the Rubik's Cube and his notation for describing moves has become standard. It just so happens that Singmaster was a friend of mine when both of us were undergrads at Caltech in the late 1950's. He subsequently went to grad school at U. C. Berkeley and shortly thereafter moved to England. He has been a math professor ever since at what is now called London South Bank University. Here is a 2018 video采访Singmaster

Singmaster使用字母L,R,U,D,F和R表示左侧,后部,向上,向下,前面和背面的顺时针旋转。而且,其中一个字母后跟一个'符号表示逆时针旋转。

我的动画

例如,这是l旋转“左”面部的动画Q0clockwise, followed by U rotating the "up" face.

F, F animation

And here is F rotating the "front" face twice.

Z, X' animation

Singmaster的符号也使用X,Y and Z to denote rotation of the entire cube. Here is Z followed by X', revealing the other three traditional colors, red, white and blue.




Published with MATLAB® R2022a

|

注释

To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.