Q_ysato_150725

3625 days ago by takepwave

Y. Sato さま、添付して頂きましたソースをDataにアップし、以下の様に動作させてみたところ、 plot3d_cubieは動いているように思います。 Dataのソースを変更し、色を調整してみてください。

def plot3d_cube(self,mv,title=True): r""" Displays `F,U,R` faces of the cube after the given move ``mv``. Mostly included for the purpose of drawing pictures and checking moves. INPUT: - ``mv`` -- A string in the Singmaster notation - ``title`` -- (Default: ``True``) Display the title information The first one below is "superflip+4 spot" (in 26q\* moves) and the second one is the superflip (in 20f\* moves). Type show(P) to view them. EXAMPLES:: sage: rubik = CubeGroup() sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") """ g = self.parse(mv) state = self.facets(g) clr_any = white shown_labels = range(1,9)+range(17,33) clr = [color_of_square(state[c-1]) for c in shown_labels] cubiesR = [plot3d_cubie(cubie_centers(c),cubie_colors(c,state)) for c in [32,31,30,29,28,27,26,25]] cubeR = sum(cubiesR) cubiesU = [plot3d_cubie(cubie_centers(c),cubie_colors(c,state)) for c in range(1,9)] cubeU = sum(cubiesU) cubiesF = [plot3d_cubie(cubie_centers(c),cubie_colors(c,state)) for c in [22,23,24,20,21]] cubeF = sum(cubiesF) centerR = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]],rgbcolor=green) centerF = polygon_plot3d([[3,1,1],[3,2,1],[3,2,2],[3,1,2],[3,1,1]],rgbcolor=red) centerU = polygon_plot3d([[1,1,3],[1,2,3],[2,2,3],[2,1,3],[1,1,3]],rgbcolor=lpurple) centers = centerF+centerR+centerU P = cubeR+cubeF+cubeU+centers P.axes(show=False) if title == True: t1 = text('Up, Front, and Right faces. ' , (-0.2,-2.5)) t2 = text(' sagemath.org', (0.8,-3.1),rgbcolor=lgrey) t3 = text(" ",(3.5,0),rgbcolor=white) P = P+t1+t2+t3 P.axes(show=False) return P return P 
       
f = [(17,19,24,22),(18,21,23,20),(6,25,43,16),(7,28,42,13),(8,30,41,11)] b = [(33,35,40,38),(34,37,39,36),(3,9,46,32),(2,12,47,29),(1,14,48,27)] l = [(9,11,16,14),(10,13,15,12),(1,17,41,40),(4,20,44,37),(6,22,46,35)] r = [(25,27,32,30),(26,29,31,28),(3,38,43,19),(5,36,45,21),(8,33,48,24)] u = [(1,3,8,6),(2,5,7,4),(9,33,25,17),(10,34,26,18),(11,35,27,19)] d = [(41,43,48,46),(42,45,47,44),(14,22,30,38),(15,23,31,39),(16,24,32,40)] cube = PermutationGroup([f,b,l,r,u,d]) F,B,L,R,U,D = cube.gens() cube.order() 
       
43252003274489856000
43252003274489856000
F.order() 
       
4
4
from sage.groups.perm_gps.cubegroup import * 
       
index2singmaster(41) 
       
'dlf'
'dlf'
rubik = CubeGroup() 
       
rubik.move(""); 
       
((), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48])
((), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48])
rubik.faces("R*L") 
       
{'right': [[27, 29, 32], [26, 0, 31], [25, 28, 30]], 'up': [[17, 2, 38],
[20, 0, 36], [22, 7, 33]], 'back': [[48, 34, 6], [45, 0, 4], [43, 39,
1]], 'down': [[40, 42, 19], [37, 0, 21], [35, 47, 24]], 'front': [[41,
18, 3], [44, 0, 5], [46, 23, 8]], 'left': [[11, 13, 16], [10, 0, 15],
[9, 12, 14]]}
{'right': [[27, 29, 32], [26, 0, 31], [25, 28, 30]], 'up': [[17, 2, 38], [20, 0, 36], [22, 7, 33]], 'back': [[48, 34, 6], [45, 0, 4], [43, 39, 1]], 'down': [[40, 42, 19], [37, 0, 21], [35, 47, 24]], 'front': [[41, 18, 3], [44, 0, 5], [46, 23, 8]], 'left': [[11, 13, 16], [10, 0, 15], [9, 12, 14]]}
P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2") 
       
show(P) 
       
clrU = orange; clrL = blue; clrF = green; clrR = (0.9, 0.9, 0.9) ; clrB = yellow; clrD = red; P4 = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) show(P4) 
       
# 以下の例は、mvが未定義なので、試すことができませんでした。 plot3d_cube(mv, title=True) plot_cube(mv, title=True, colors=[(1, 0.63, 1), (1, 1, 0), (1, 0, 0), (0, 1, 0), (1, 0.6, 0.3), (0, 0, 1)]) rubik = CubeGroup() P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", \ colors=[orange, (0, 0, 1), (0, 1, 0), (0.9, 0.9, 0.9), (1, 0.9, 0), (1, 0, 0)]); show(P) 
       
Traceback (click to the left of this block for traceback)
...
NameError: name 'mv' is not defined
Traceback (most recent call last):    P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", \
  File "", line 1, in <module>
    
  File "/tmp/tmpKFGFam/___code___.py", line 3, in <module>
    plot3d_cube(mv, title=True)
NameError: name 'mv' is not defined