Saturday, October 1, 2022
HomeMatlabDigital Simulation of Rubik’s Dice » Cleve’s Nook: Cleve Moler on Arithmetic...

Digital Simulation of Rubik’s Dice » Cleve’s Nook: Cleve Moler on Arithmetic and Computing

Rubik’s Dice is among the nice mathematical puzzles of all time. Most individuals are simply inquisitive about fixing Rubik’s Dice quickly, however deeper investigation reveals a wealthy mathematical and computational construction. A digital Rubik’s Dice simulator supplies a laboratory for the research of linear algebra, group idea, information buildings and pc graphics.



Our summary Rubik’s Dice is comprised of 27 an identical copies of a small dice that I name a cubelet. Within the first view beneath you see three of the normal colours for the cubelet faces — inexperienced, white and orange. Rotating the cubelet, you see that the face reverse the white face is yellow and the face reverse orange face is pink. Rotation a couple of totally different axis would reveal that the face reverse the inexperienced face is blue.


4 varieties

An ingenious spring mechanism holds an precise bodily Rubik’s Dice collectively whereas permitting rotation of its faces. Then again, our pc mannequin of the puzzle doesn’t contain any springs and its faces are rotated by 3-by-3 matrices.

The 27 cubelets within the mannequin have 4 varieties — heart, face, edge and nook. The middle cubelet isn’t seen and rotates solely when the perspective of all the puzzle is rotated.

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

There are twelve cubelets in the course of the twelve puzzle edges. Every edge cubelet exhibits two colours from its related faces, green-white, white-orange and so forth. There isn’t any orange-red edge dice as a result of the orange and pink faces of the puzzle by no means share a standard edge.

There are eight nook cubelets, every displaying three colours, green-white-orange, green-orange-yellow, and so forth. Of the 6x5x4 = 120 potential mixtures of six colours, solely eight are wanted for the nook cubes.

Here’s what would occur when you begin with the middle plus the six face cubelets, then add the twelve edge cubelets, and at last add the eight nook cubelets.



I’ll use capital letters Q to indicate cubes. A dice is a 3-by-3-by-3 cell array. Every cell accommodates the vertices of a cubelet, saved in an 8-by-3 matrix of doubles. That is a complete of 27 vertex matrices, every able to be multiplied a rotation. Making use of the identical rotation to all 27 cubelets in a dice rotates all the dice. It is extra fascinating to use a given rotation to the 9 cubelets in one of many dice faces, whereas leaving the opposite 18 cubelets unchanged.

I’ll use Q0 to indicate the puzzle that has all of the cubelets in a face displaying the identical colour.



The code for producing Q0 begins with a matrix v containing the vertices of the middle cubelet, qzero.

     kind qzero

operate 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];

With loop variables x, y and z that tackle all potential mixtures of -2, 0 and +2, the innermost assertion includes the amount

  v + [x y z]

That is the sum of a matrix and a vector, which isn’t outlined in typical linear algebra. MATLAB singleton enlargement rewrites this because the sum of two matrices. So, x, y and z are the coordinates of cubelet facilities, and the output cell array has the vertices of all of the cubelets in Q0.

    kind Q0.m

operate Q = Q0(w)
    if nargin < 1
        w = width;
    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];

David Singmaster

David Singmaster was one of many first mathematicians to research the Rubik’s Dice and his notation for describing strikes has develop into commonplace. It simply so occurs that Singmaster was a good friend of mine when each of us have been undergrads at Caltech within the late 1950’s. He subsequently went to grad college at U. C. Berkeley and shortly thereafter moved to England. He has been a math professor ever since at what’s now known as London South Financial institution College. Here’s a 2018 video interview with Singmaster.

Singmaster makes use of the letters L, R, U, D, F and R to indicate clockwise rotation of the Left, Rear, Up, Down, Entrance and Again faces. And, one in every of these letters adopted by a ' image denotes counterclockwise rotation.

L,U animation

For instance, right here is an animation of L rotating the “left” face of Q0 clockwise, adopted by U rotating the “up” face.

F, F animation

And right here is F rotating the “entrance” face twice.

Z, X’ animation

Singmaster’s notation additionally makes use of X, Y and Z to indicate rotation of all the dice. Right here is Z adopted by X’, revealing the opposite three conventional colours, pink, white and blue.

Revealed with MATLAB® R2022a



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments