Thursday, April 25, 2024
HomeMatlabDigital Simulation of Rubik’s Dice with Qube » Cleve’s Nook: Cleve Moler...

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


This weblog submit describes Qube, my Rubik’s Dice simulator. Supply code for Qube is now accessible in one single file from this hyperlink: Qube_osf.m. I will even submit the code to the MATLAB Central File Alternate. As regular, I welcome any suggestions.

Contents

Qube

Right here is the opening display for Qube.

dice

The dice is displayed within the middle of the simulator.

stack

The present stack is displayed on this textual content field over the dice.

keys

Eighteen keys use Singmaster notation to generate rotations which can be pushed onto the stack.

Scramble

The 2 buttons on the decrease proper scramble the dice. The => button applies any rotations within the stack to the present dice. To use them to Q0, use Q0 earlier than =>

The ==> button is a toggle that generates repeated random rotations till it’s turned off. A contemporary scramble is produced each time I publish this file.

    show_randdo(3,3)
    snapnow

Unscramble

The 2 buttons on the decrease left unscramble the dice. The <= button generates a rotation within the route reverse the rotation on the high of the stack. This acts like a backspace. The <== toggle repeatedly backspaces till the stack is empty. That is the good solution to “clear up” the puzzle — keep in mind the way it was scrambled.

Let’s unscramble the dice and get again to Q0.

    show_undo(3,3)
    snapnow

Look

The buttons within the left-hand group management the looks of the simulator.

width

The vertices of the essential unit cubelet, qzero, are the eight combos of +1 and -1, so the half-width of qzero is one. The twenty-seven cubelets in Q0 are scaled by this width parameter to supply gaps between the person cubelets.

    show_width(1,3)
    snapnow

nstep

The variety of fractional rotations in 1 / 4 flip controls Qube's velocity.

sort

The cubelet facilities are the factors [x,y,z] the place x, y and z are combos of -2, 0 and a couple of. The cubelet sort is the variety of nonzeros in coordinates of its middle, nnz([x,y,z]).

* 0: middle
* 1: face
* 2: edge
* 3: nook
    show_types
    snapnow

shade

An alternative choice to the normal Rubik’s colours produced from the MATLAB axes shade order.

    show_color(1,3)
    snapnow

mouse

This button activates Deal with Graphics rotate3d. You’ll be able to then use your mouse to rotate the point of view. The visible impact is identical as rotating all the dice.

Actions

The buttons within the right-hand group provoke computations. Different instruments could also be added.

clear up

Experimental solver. Grasping algorithm to reduce the sum of SVDs of the distinction between the cubelets within the present dice and cubelets in Q0. Also referred to as the nuclear norm. It seems that this solver doesn’t work very nicely.

interval

Variety of repetitions to return to Q0. A elementary notion in group concept.

reset

Reinitialize with out restarting.

restart

Full restart.

Q0

Restore Q0.

Higher left-hand aspect

rating

At the moment, the nuclear norm distance to Q0. Want one thing extra delicate to Rubik’s dice patterns.

rely

Variety of rotations. Therefore, the interval.

submit

Most up-to-date rotation.

Higher right-hand aspect

assist

helpwin Qube

information

Pointer to this weblog submit.

Software program

The supply code for Qube is out there from this hyperlink: Qube_osf.m. The osf, one single file, format is a self-extracting archive that expands right into a listing of particular person features.

Printed with MATLAB® R2022a

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments