How to shuffle a Rubik's cube?
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}
newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}
edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Question:
Is there an another way without using the package arrayjob?
How to get the random color for it?
Thanks.
pstricks pst-solides3d
add a comment |
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}
newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}
edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Question:
Is there an another way without using the package arrayjob?
How to get the random color for it?
Thanks.
pstricks pst-solides3d
1
As for 2.: you are already loadingpgf
, so you have already a built in way to get a random item. Just addpgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.
– marmot
Feb 21 at 14:51
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13
add a comment |
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}
newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}
edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Question:
Is there an another way without using the package arrayjob?
How to get the random color for it?
Thanks.
pstricks pst-solides3d
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}
newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}
edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Question:
Is there an another way without using the package arrayjob?
How to get the random color for it?
Thanks.
pstricks pst-solides3d
pstricks pst-solides3d
edited Feb 22 at 3:11
The Inventor of God
4,93211041
4,93211041
asked Feb 21 at 13:21
chishimutojichishimutoji
8201320
8201320
1
As for 2.: you are already loadingpgf
, so you have already a built in way to get a random item. Just addpgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.
– marmot
Feb 21 at 14:51
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13
add a comment |
1
As for 2.: you are already loadingpgf
, so you have already a built in way to get a random item. Just addpgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.
– marmot
Feb 21 at 14:51
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13
1
1
As for 2.: you are already loading
pgf
, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.– marmot
Feb 21 at 14:51
As for 2.: you are already loading
pgf
, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.– marmot
Feb 21 at 14:51
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13
add a comment |
1 Answer
1
active
oldest
votes
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
0 1 8 { from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop
Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.
The same for complete faces:
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
|
show 5 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475995%2fhow-to-shuffle-a-rubiks-cube%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
0 1 8 { from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop
Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.
The same for complete faces:
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
|
show 5 more comments
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
0 1 8 { from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop
Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.
The same for complete faces:
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
|
show 5 more comments
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
0 1 8 { from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop
Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.
The same for complete faces:
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
0 1 8 { from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop
Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.
The same for complete faces:
documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}
edited Feb 21 at 17:17
answered Feb 21 at 16:08
HerbertHerbert
275k24418730
275k24418730
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
|
show 5 more comments
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
Please to answer the first question. Your code(PostScript language) is new with me...
– chishimutoji
Feb 21 at 16:36
see edited answer ...
– Herbert
Feb 21 at 16:45
see edited answer ...
– Herbert
Feb 21 at 16:45
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..
– chishimutoji
Feb 21 at 16:54
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)
– chishimutoji
Feb 21 at 17:02
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
I see only 5 colors. pages 38ff show anything about colors.
– Herbert
Feb 21 at 17:09
|
show 5 more comments
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475995%2fhow-to-shuffle-a-rubiks-cube%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
As for 2.: you are already loading
pgf
, so you have already a built in way to get a random item. Just addpgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c}
to your code.– marmot
Feb 21 at 14:51
It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.
– John Kormylo
Feb 21 at 23:47
Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.
– The Inventor of God
Feb 22 at 3:13