Package sage :: Package groups :: Package perm_gps :: Module cubegroup
[hide private]
[frames] | no frames]

Module cubegroup

source code


Rubik's cube group functions
\label{sec:rubik}

NOTE: ``Rubik's cube'' is trademarked. We shall omit the trademark symbol
below for simplcity.

NOTATION: B denotes a clockwise quarter turn of the back face
          D denotes a clockwise quarter turn of the down face
          and similarly for F (front), L (left), R (right), U (up)
          Products of moves are read {\it right to left}, so for example,
          R*U means move U first and then R.
          
See \code{CubeGroup.parse()} for all possible input notations. 
          
The "Singmaster notation": 
  * moves: U, D, R, L, F, B as in the diagram below,
  * corners: xyz means the facet is on face x (in R,F,L,U,D,B) 
     and the clockwise rotation of the corner sends x->y->z 
  * edges: xy means the facet is on face x and a flip of the edge sends x->y.

            sage: rubik = CubeGroup()
            sage: rubik.display2d("")
                         +--------------+
                         |  1    2    3 |
                         |  4   top   5 |
                         |  6    7    8 |
            +------------+--------------+-------------+------------+
            |  9  10  11 | 17   18   19 | 25   26  27 | 33  34  35 |
            | 12 left 13 | 20  front 21 | 28 right 29 | 36 rear 37 |
            | 14  15  16 | 22   23   24 | 30   31  32 | 38  39  40 |
            +------------+--------------+-------------+------------+
                         | 41   42   43 |
                         | 44 bottom 45 |
                         | 46   47   48 |
                         +--------------+

AUTHOR:
    - David Joyner (2006-10-21): first version
    -      "       (2007-05): changed faces, added legal and solve
    -      "       (2007-06): added plotting functions
    -      "       (2007-08): colors corrected, "solve" rewritten (again),typos fixed.
    - Robert Miller (2007-08): editing, cleaned up display2d
    - Robert Bradshaw (2007-08): RubiksCube object, 3d plotting.
    - DJ (2007-09): rewrote docstring for CubeGroup's "solve".
    - Robert Bradshaw (2007-09): Versatile parse function for all input types.
    - Robert Bradshaw (2007-11): Cleanup.
    
REFERENCES:
    Cameron, P., Permutation Groups. New York: Cambridge University Press, 1999.
    Wielandt, H., Finite Permutation Groups. New York: Academic Press, 1964.
    Dixon, J. and Mortimer, B., Permutation Groups, Springer-Verlag, Berlin/New York, 1996. 
    Joyner, D, Adventures in Group Theory, Johns Hopkins Univ Press, 2002.
    



Classes [hide private]
  CubeGroup
A python class to help compute Rubik's cube group actions.
  RubiksCube
sage: C = RubiksCube().move("R U R'")...
Functions [hide private]
 
xproj(x, y, z, r) source code
 
yproj(x, y, z, r) source code
 
rotation_list(tilt, turn) source code
 
polygon_plot3d(points, tilt=30, turn=30, **kwargs)
Plots a polygon viewed from an angle determined by tilt, turn, and vertices points.
source code
 
inv_list(lst)
Input a list of ints 1, ..., m (in any order), outputs inverse perm.
source code
 
create_poly(face, color) source code
 
index2singmaster(facet)
Translates index used (eg, 43) to Singmaster facet notation (eg, fdr).
source code
 
color_of_square(facet, colors=['lpurple', 'yellow', 'red', 'green', 'orange', 'blue'])
Returns the color the facet has in the solved state.
source code
 
cubie_centers(label) source code
 
cubie_colors(label, state0) source code
 
plot3d_cubie(cnt, clrs)
Plots the front, up and right face of a cubie centered at cnt and rgbcolors given by clrs (in the order FUR).
source code
 
cubie_faces()
This provides a map from the 6 faces of the 27 cubies to the 48 facets of the larger cube.
source code
Variables [hide private]
  polygon = Sage polygon; type polygon? for help and examples
  text = type text? for help and examples
  pi = 3.14159265359
  named_colors = {'blue': (0, 0, 1), 'green': (0, 1, 0), 'lgrey'...
  face_polys = {'b_center': [[7, 1], [8, 1], [8, 2], [7, 2]], 'b...
  singmaster_indices = {1: 'ulb', 2: 'ub', 3: 'ubr', 4: 'ul', 5:...
  cubie_center_list = {1: [0, 0, 2], 2: [0, 1, 2], 3: [0, 2, 2],...
  cubie_face_list = {(-1, -1, -1): [6, 17, 11, 0, 0, 0], (-1, -1...
  rand_colors = [(0.681267654873, 0.467121210151, 0.837754864021...
  _ = 55
  blue = (0, 0, 1)
  green = (0, 1, 0)
  lgrey = (0.75, 0.75, 0.75)
  lightblue = (0, 1, 1)
  lpurple = (1, 0.63, 1)
  orange = (1, 0.6, 0.3)
  purple = (1, 0, 1)
  red = (1, 0, 0)
  white = (1, 1, 1)
  yellow = (1, 1, 0)
Function Details [hide private]

polygon_plot3d(points, tilt=30, turn=30, **kwargs)

source code 

Plots a polygon viewed from an angle determined by tilt, turn, and vertices
points. 

WARNING: The ordering of the points is important to get "correct" and
if you add several of these plots together, the one added first is also
drawn first (ie, addition of Graphics objects is not commutative).

The following example produced a green-colored square with vertices
at the points indicated.

EXAMPLES:
    sage: from sage.groups.perm_gps.cubegroup import *
    sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]],rgbcolor=green)

inv_list(lst)

source code 

Input a list of ints 1, ..., m (in any order), outputs inverse perm.

EXAMPLES:
    sage: from sage.groups.perm_gps.cubegroup import *
    sage: L = [2,3,1]
    sage: inv_list(L)
    [3, 1, 2]

index2singmaster(facet)

source code 

Translates index used (eg, 43) to Singmaster facet notation (eg, fdr).

EXAMPLES:
    sage: from sage.groups.perm_gps.cubegroup import *
    sage: index2singmaster(41)        
    'dlf'

color_of_square(facet, colors=['lpurple', 'yellow', 'red', 'green', 'orange', 'blue'])

source code 

Returns the color the facet has in the solved state.

EXAMPLES:
    sage: from sage.groups.perm_gps.cubegroup import *
    sage: color_of_square(41)
    'blue'

plot3d_cubie(cnt, clrs)

source code 

Plots the front, up and right face of a cubie centered at cnt and rgbcolors given by clrs (in the
order FUR).

Type P.show() to view.

EXAMPLES:
    sage: from sage.groups.perm_gps.cubegroup import *
    sage: clrF = blue; clrU = red; clrR = green
    sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR])

cubie_faces()

source code 

This provides a map from the 6 faces of the 27 cubies to the 48 facets of the larger cube. 

-1,-1,-1 is left, top, front


Variables Details [hide private]

named_colors

Value:
{'blue': (0, 0, 1),
 'green': (0, 1, 0),
 'lgrey': (0.75, 0.75, 0.75),
 'lightblue': (0, 1, 1),
 'lpurple': (1, 0.63, 1),
 'orange': (1, 0.6, 0.3),
 'purple': (1, 0, 1),
 'red': (1, 0, 0),
...

face_polys

Value:
{'b_center': [[7, 1], [8, 1], [8, 2], [7, 2]],
 'bd': [[7, 0], [8, 0], [8, 1], [7, 1]],
 'bdr': [[6, 0], [7, 0], [7, 1], [6, 1]],
 'bl': [[8, 1], [9, 1], [9, 2], [8, 2]],
 'bld': [[8, 0], [9, 0], [9, 1], [8, 1]],
 'br': [[6, 1], [7, 1], [7, 2], [6, 2]],
 'bu': [[7, 2], [8, 2], [8, 3], [7, 3]],
 'bul': [[8, 2], [9, 2], [9, 3], [8, 3]],
...

singmaster_indices

Value:
{1: 'ulb',
 2: 'ub',
 3: 'ubr',
 4: 'ul',
 5: 'ur',
 6: 'ufl',
 7: 'uf',
 8: 'urf',
...

cubie_center_list

Value:
{1: [0, 0, 2],
 2: [0, 1, 2],
 3: [0, 2, 2],
 4: [1, 0, 2],
 5: [1, 2, 2],
 6: [2, 0, 2],
 7: [2, 1, 2],
 8: [2, 2, 2],
...

cubie_face_list

Value:
{(-1, -1, -1): [6, 17, 11, 0, 0, 0],
 (-1, -1, 0): [4, 0, 10, 0, 0, 0],
 (-1, -1, 1): [1, 0, 9, 0, 35, 0],
 (-1, 0, -1): [0, 20, 13, 0, 0, 0],
 (-1, 0, 0): [0, 0, -5, 0, 0, 0],
 (-1, 0, 1): [0, 0, 12, 0, 37, 0],
 (-1, 1, -1): [0, 22, 16, 41, 0, 0],
 (-1, 1, 0): [0, 0, 15, 44, 0, 0],
...

rand_colors

Value:
[(0.681267654873, 0.467121210151, 0.837754864021),
 (0.882152738714, -0.482310508423, -0.295705431629),
 (-0.360215863936, 0.0301424616185, -0.129004993688),
 (-0.0904937020409, 0.94235970912, -0.304416555688),
 (0.556961291221, 0.0971376341043, 0.937514461777),
 (-0.662198998463, -0.214857932473, -0.310600984014),
 (0.844100439055, 0.681924948008, 0.436635110181),
 (0.625279892154, -0.866826116772, -0.751687415484),
...