How to draw a cube as the following?Aligning a text in 3d diagramTikz Fractal - Menger SpongeHow can I draw a transparent cube in 3D perspective?Pst-Solides3D Transformation of a Cube with parameterDraw 3D lines between points with PSTricksHow to draw this cube with PSTrick or TikZ?TikZ - How to draw the followingHow does one draw the following graph?LaTeX Trellis Diagrams for STBCspst-solides3d: Draw squares between othersHow to draw closed path if used the following code:How to shuffle a Rubik's cube?
How do I change two letters closest to a string and one letter immediately after a string using Notepad++?
"of which" is correct here?
Shortcut for setting origin to vertex
How do you talk to someone whose loved one is dying?
Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?
Why Choose Less Effective Armour Types?
Are relativity and doppler effect related?
Recruiter wants very extensive technical details about all of my previous work
How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?
Adventure Game (text based) in C++
Did Ender ever learn that he killed Stilson and/or Bonzo?
Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible
Violin - Can double stops be played when the strings are not next to each other?
ERC721: How to get the owned tokens of an address
A single argument pattern definition applies to multiple-argument patterns?
Examples of transfinite towers
combinatorics floor summation
Planetary tidal locking causing asymetrical water distribution
Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?
How to write cleanly even if my character uses expletive language?
Bacteria contamination inside a thermos bottle
Do I need life insurance if I can cover my own funeral costs?
Why no Iridium-level flares from other satellites?
This word with a lot of past tenses
How to draw a cube as the following?
Aligning a text in 3d diagramTikz Fractal - Menger SpongeHow can I draw a transparent cube in 3D perspective?Pst-Solides3D Transformation of a Cube with parameterDraw 3D lines between points with PSTricksHow to draw this cube with PSTrick or TikZ?TikZ - How to draw the followingHow does one draw the following graph?LaTeX Trellis Diagrams for STBCspst-solides3d: Draw squares between othersHow to draw closed path if used the following code:How to shuffle a Rubik's cube?
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 50 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
deffigure#1#2%
beginpspicture(-3,-3)(3,3)
psframe[linestyle=none,fillstyle=solid,fillcolor=blue!50](-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=3,%
rm=4 40 13 31 53 22,hollow,incolor=pink!50,Rot#2=-#1space]%
endpspicture
multidoiA=0+572figureiAX
enddocument

It is hollowed inside the cube.
So, how to get the similar output to the following image?

%% From Herbert's comment
documentclass[pstricks]standalone
usepackagepst-solides3d
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 35 15 rtp2xyz,a=1,lightsrc=80 30 20,
% psSolid[object=grille,base=0 7 0 7,fillcolor=gray!40]%%
% psSolid[object=grille,base=0 7 0 7,RotY=90,fillcolor=gray!30](0,0,7)%
% psSolid[object=grille,base=0 7 0 7,RotX=-90,fillcolor=gray!20](0,0,7)%
deffigure#1#2#3psSolid[object=cube,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
foreach i in 0.5,1.5,2.5figure0.5i0.5
foreach i in 1.5,2.5figurei.50.5
figure1.52.50.5
foreach i in 1.5,2.5figure2.5i0.5
foreach i in 1.5,2.5figure.5.5i
figure2.5.51.5
figure.51.52.5
foreach i in 1.5,2.5figurei.52.5
figure2.51.52.5
foreach i in 1.5,2.5figure.52.5i
figure1.52.52.5
foreach i in 1.5,2.5figure2.52.5i
endpspicture
enddocument

But with viewpoint=80 135 15 rtp2xyz , I get the following:

pstricks pst-solides3d
add a comment |
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 50 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
deffigure#1#2%
beginpspicture(-3,-3)(3,3)
psframe[linestyle=none,fillstyle=solid,fillcolor=blue!50](-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=3,%
rm=4 40 13 31 53 22,hollow,incolor=pink!50,Rot#2=-#1space]%
endpspicture
multidoiA=0+572figureiAX
enddocument

It is hollowed inside the cube.
So, how to get the similar output to the following image?

%% From Herbert's comment
documentclass[pstricks]standalone
usepackagepst-solides3d
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 35 15 rtp2xyz,a=1,lightsrc=80 30 20,
% psSolid[object=grille,base=0 7 0 7,fillcolor=gray!40]%%
% psSolid[object=grille,base=0 7 0 7,RotY=90,fillcolor=gray!30](0,0,7)%
% psSolid[object=grille,base=0 7 0 7,RotX=-90,fillcolor=gray!20](0,0,7)%
deffigure#1#2#3psSolid[object=cube,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
foreach i in 0.5,1.5,2.5figure0.5i0.5
foreach i in 1.5,2.5figurei.50.5
figure1.52.50.5
foreach i in 1.5,2.5figure2.5i0.5
foreach i in 1.5,2.5figure.5.5i
figure2.5.51.5
figure.51.52.5
foreach i in 1.5,2.5figurei.52.5
figure2.51.52.5
foreach i in 1.5,2.5figure.52.5i
figure1.52.52.5
foreach i in 1.5,2.5figure2.52.5i
endpspicture
enddocument

But with viewpoint=80 135 15 rtp2xyz , I get the following:

pstricks pst-solides3d
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to useasymptoteyou might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)
– marmot
Mar 11 at 16:10
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinatespsSolid[object=cube,..](x,y,z). That's all
– Herbert
Mar 11 at 17:27
You have to usesolidmemory, action=none,name=cubeXXXand then an objectfusion. See documentation for a lot of examples. Without theobject=fusionyou cannot have hidden surfaces.
– Herbert
Mar 11 at 18:36
see extended answer
– Herbert
Mar 12 at 6:42
add a comment |
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 50 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
deffigure#1#2%
beginpspicture(-3,-3)(3,3)
psframe[linestyle=none,fillstyle=solid,fillcolor=blue!50](-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=3,%
rm=4 40 13 31 53 22,hollow,incolor=pink!50,Rot#2=-#1space]%
endpspicture
multidoiA=0+572figureiAX
enddocument

It is hollowed inside the cube.
So, how to get the similar output to the following image?

%% From Herbert's comment
documentclass[pstricks]standalone
usepackagepst-solides3d
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 35 15 rtp2xyz,a=1,lightsrc=80 30 20,
% psSolid[object=grille,base=0 7 0 7,fillcolor=gray!40]%%
% psSolid[object=grille,base=0 7 0 7,RotY=90,fillcolor=gray!30](0,0,7)%
% psSolid[object=grille,base=0 7 0 7,RotX=-90,fillcolor=gray!20](0,0,7)%
deffigure#1#2#3psSolid[object=cube,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
foreach i in 0.5,1.5,2.5figure0.5i0.5
foreach i in 1.5,2.5figurei.50.5
figure1.52.50.5
foreach i in 1.5,2.5figure2.5i0.5
foreach i in 1.5,2.5figure.5.5i
figure2.5.51.5
figure.51.52.5
foreach i in 1.5,2.5figurei.52.5
figure2.51.52.5
foreach i in 1.5,2.5figure.52.5i
figure1.52.52.5
foreach i in 1.5,2.5figure2.52.5i
endpspicture
enddocument

But with viewpoint=80 135 15 rtp2xyz , I get the following:

pstricks pst-solides3d
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 50 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
deffigure#1#2%
beginpspicture(-3,-3)(3,3)
psframe[linestyle=none,fillstyle=solid,fillcolor=blue!50](-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=3,%
rm=4 40 13 31 53 22,hollow,incolor=pink!50,Rot#2=-#1space]%
endpspicture
multidoiA=0+572figureiAX
enddocument

It is hollowed inside the cube.
So, how to get the similar output to the following image?

%% From Herbert's comment
documentclass[pstricks]standalone
usepackagepst-solides3d
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 35 15 rtp2xyz,a=1,lightsrc=80 30 20,
% psSolid[object=grille,base=0 7 0 7,fillcolor=gray!40]%%
% psSolid[object=grille,base=0 7 0 7,RotY=90,fillcolor=gray!30](0,0,7)%
% psSolid[object=grille,base=0 7 0 7,RotX=-90,fillcolor=gray!20](0,0,7)%
deffigure#1#2#3psSolid[object=cube,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
foreach i in 0.5,1.5,2.5figure0.5i0.5
foreach i in 1.5,2.5figurei.50.5
figure1.52.50.5
foreach i in 1.5,2.5figure2.5i0.5
foreach i in 1.5,2.5figure.5.5i
figure2.5.51.5
figure.51.52.5
foreach i in 1.5,2.5figurei.52.5
figure2.51.52.5
foreach i in 1.5,2.5figure.52.5i
figure1.52.52.5
foreach i in 1.5,2.5figure2.52.5i
endpspicture
enddocument

But with viewpoint=80 135 15 rtp2xyz , I get the following:

pstricks pst-solides3d
pstricks pst-solides3d
edited Mar 12 at 6:46
chishimutoji
asked Mar 11 at 15:40
chishimutojichishimutoji
9781321
9781321
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to useasymptoteyou might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)
– marmot
Mar 11 at 16:10
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinatespsSolid[object=cube,..](x,y,z). That's all
– Herbert
Mar 11 at 17:27
You have to usesolidmemory, action=none,name=cubeXXXand then an objectfusion. See documentation for a lot of examples. Without theobject=fusionyou cannot have hidden surfaces.
– Herbert
Mar 11 at 18:36
see extended answer
– Herbert
Mar 12 at 6:42
add a comment |
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to useasymptoteyou might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)
– marmot
Mar 11 at 16:10
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinatespsSolid[object=cube,..](x,y,z). That's all
– Herbert
Mar 11 at 17:27
You have to usesolidmemory, action=none,name=cubeXXXand then an objectfusion. See documentation for a lot of examples. Without theobject=fusionyou cannot have hidden surfaces.
– Herbert
Mar 11 at 18:36
see extended answer
– Herbert
Mar 12 at 6:42
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to use
asymptote you might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)– marmot
Mar 11 at 16:10
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to use
asymptote you might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)– marmot
Mar 11 at 16:10
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinates
psSolid[object=cube,..](x,y,z). That's all– Herbert
Mar 11 at 17:27
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinates
psSolid[object=cube,..](x,y,z). That's all– Herbert
Mar 11 at 17:27
You have to use
solidmemory, action=none,name=cubeXXX and then an object fusion. See documentation for a lot of examples. Without the object=fusion you cannot have hidden surfaces.– Herbert
Mar 11 at 18:36
You have to use
solidmemory, action=none,name=cubeXXX and then an object fusion. See documentation for a lot of examples. Without the object=fusion you cannot have hidden surfaces.– Herbert
Mar 11 at 18:36
see extended answer
– Herbert
Mar 12 at 6:42
see extended answer
– Herbert
Mar 12 at 6:42
add a comment |
2 Answers
2
active
oldest
votes
If you do not want the inside also with cubes, it is simple:
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 60 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
beginpspicture(-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
rm= 8 12 24 36 40
57 61 73 85 89
106 110 122 134 138
155 159 171 183 187
208 212 220 228 232
269 273 281 289 293,
hollow,incolor=blue!30]%
endpspicture
enddocument

And as single cubes:
documentclass[pstricks]standalone
usepackagepst-solides3d
defFigure#1#2#3#4%
psSolid[object=cube,name=c#4,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory
foreach i/j in 0.5/1,1.5/2,2.5/3Figure0.5i0.5j
foreach i/j in 1.5/4,2.5/5Figurei.50.5j
Figure1.52.50.56
foreach i/j in 1.5/7,2.5/8Figure2.5i0.5j
foreach i/j in 1.5/9,2.5/10Figure.5.5ij
Figure2.5.51.511
Figure.51.52.512
foreach i/j in 1.5/13,2.5/14Figurei.52.5j
Figure2.51.52.515
foreach i/j in 1.5/16,2.5/17Figure.52.5ij
Figure1.52.52.518
foreach i/j in 1.5/19,2.5/20Figure2.52.5ij
psSolid[object=fusion,
base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
composeSolid
endpspicture
enddocument

For a lot of cubes you can simplify the fusion object:
defcubes
multidoiA=1+120xdefcubescubesspace ciA
beginpspicture ....
....
psSolid[object=fusion, base=cubes]
....
and here is a way how you can build the complete cube:
documentclass[pstricks]standalone
usepackagepst-solides3d
newcounterfig
defFigure#1#2#3%
stepcounterfig%
psSolid[object=cube,name=cthefig,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-5,-3.5)(4,6)
pssetDecran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory
multidoiA=0+17%
multidoiB=0+17%
multidoiC=0+17%
FigureiBiAiC%
%
psSolid[object=fusion, base=
% 1
c1 c2 c3 c4 c5 c6 c7
c8 c10 c11 c12 c14
c15 c16 c17 c18 c19 c20 c21
c22 c23 c24 c26 c27 c28
c29 c30 c31 c32 c33 c34 c35
c36 c38 c39 c40 c42
c43 c44 c45 c46 c47 c48 c49
% 2
c50 c52 c53 c54 c56
%
c64 c66 c67 c68 c70
c71 c73 c75 c77
c78 c80 c81 c82 c84
%
c92 c94 c95 c96 c98
% 3 ...
]
composeSolid
endpspicture
enddocument

and the complete image:

Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
|
show 1 more comment
Something like this?
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrarycalc
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
unit xy plane/.style=plane=#1(1,0,0)(0,1,0),
unit xz plane/.style=plane=#1(1,0,0)(0,0,1),
unit yz plane/.style=plane=#1(0,1,0)(0,0,1),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/unit cube/.style=code=
path[get projections];
draw (0,0,0) -- (1,1,1);
ifnumzproj=-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,0)];
fi
ifnumyproj=1
path[3d cube/every face,3d cube/yz face,unit yz plane=(1,0,0)];
else
path[3d cube/every face,3d cube/yz face,unit yz plane=(0,0,0)];
fi
ifnumxproj=1
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,0,0)];
else
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,1,0)];
fi
ifnumzproj>-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,1)];
fi
,
3d cube/.cd,
xy face/.style=fill=orange,
xz face/.style=fill=blue,
yz face/.style=fill=red,
every face/.style=draw,very thick
begindocument
foreach Angle in 5,15,...,355
tdplotsetmaincoords60Angle % the first argument cannot be larger than 90
begintikzpicture[line join=round]
pgfmathtruncatemacroNumCubes7
path[use as bounding box] (-NumCubes/2-3,-NumCubes/2-2)
rectangle (NumCubes/2+3,NumCubes/2+4);
beginscope[tdplot_main_coords]
pgfmathtruncatemacroNextToLastNumCubes-1
path[get projections];
ifnumyproj=1
defLstX1,...,NumCubes
else
defLstXNumCubes,NextToLast,...,1
fi
ifnumxproj=-1
defLstY1,...,NumCubes
else
defLstYNumCubes,NextToLast,...,1
fi
ifnumzproj=1
defLstZ1,...,NumCubes
else
defLstZNumCubes,NextToLast,...,1
fi
foreach X in LstX
foreach Y in LstY
foreach Z in LstZ
xdefitest1
ifoddX
else
pgfmathtruncatemacrojtestmod(X+Y,4)
ifnumjtest=0
xdefitest0
fi
pgfmathtruncatemacrojtestmod(X+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifoddY
else
pgfmathtruncatemacrojtestmod(Y+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifnumitest=1
path (X-NumCubes/2-1/2,Y-NumCubes/2-1/2,Z-NumCubes/2-1/2) picunit cube;
fi
endscope
endtikzpicture
enddocument

2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
add a comment |
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%2f478922%2fhow-to-draw-a-cube-as-the-following%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you do not want the inside also with cubes, it is simple:
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 60 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
beginpspicture(-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
rm= 8 12 24 36 40
57 61 73 85 89
106 110 122 134 138
155 159 171 183 187
208 212 220 228 232
269 273 281 289 293,
hollow,incolor=blue!30]%
endpspicture
enddocument

And as single cubes:
documentclass[pstricks]standalone
usepackagepst-solides3d
defFigure#1#2#3#4%
psSolid[object=cube,name=c#4,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory
foreach i/j in 0.5/1,1.5/2,2.5/3Figure0.5i0.5j
foreach i/j in 1.5/4,2.5/5Figurei.50.5j
Figure1.52.50.56
foreach i/j in 1.5/7,2.5/8Figure2.5i0.5j
foreach i/j in 1.5/9,2.5/10Figure.5.5ij
Figure2.5.51.511
Figure.51.52.512
foreach i/j in 1.5/13,2.5/14Figurei.52.5j
Figure2.51.52.515
foreach i/j in 1.5/16,2.5/17Figure.52.5ij
Figure1.52.52.518
foreach i/j in 1.5/19,2.5/20Figure2.52.5ij
psSolid[object=fusion,
base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
composeSolid
endpspicture
enddocument

For a lot of cubes you can simplify the fusion object:
defcubes
multidoiA=1+120xdefcubescubesspace ciA
beginpspicture ....
....
psSolid[object=fusion, base=cubes]
....
and here is a way how you can build the complete cube:
documentclass[pstricks]standalone
usepackagepst-solides3d
newcounterfig
defFigure#1#2#3%
stepcounterfig%
psSolid[object=cube,name=cthefig,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-5,-3.5)(4,6)
pssetDecran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory
multidoiA=0+17%
multidoiB=0+17%
multidoiC=0+17%
FigureiBiAiC%
%
psSolid[object=fusion, base=
% 1
c1 c2 c3 c4 c5 c6 c7
c8 c10 c11 c12 c14
c15 c16 c17 c18 c19 c20 c21
c22 c23 c24 c26 c27 c28
c29 c30 c31 c32 c33 c34 c35
c36 c38 c39 c40 c42
c43 c44 c45 c46 c47 c48 c49
% 2
c50 c52 c53 c54 c56
%
c64 c66 c67 c68 c70
c71 c73 c75 c77
c78 c80 c81 c82 c84
%
c92 c94 c95 c96 c98
% 3 ...
]
composeSolid
endpspicture
enddocument

and the complete image:

Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
|
show 1 more comment
If you do not want the inside also with cubes, it is simple:
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 60 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
beginpspicture(-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
rm= 8 12 24 36 40
57 61 73 85 89
106 110 122 134 138
155 159 171 183 187
208 212 220 228 232
269 273 281 289 293,
hollow,incolor=blue!30]%
endpspicture
enddocument

And as single cubes:
documentclass[pstricks]standalone
usepackagepst-solides3d
defFigure#1#2#3#4%
psSolid[object=cube,name=c#4,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory
foreach i/j in 0.5/1,1.5/2,2.5/3Figure0.5i0.5j
foreach i/j in 1.5/4,2.5/5Figurei.50.5j
Figure1.52.50.56
foreach i/j in 1.5/7,2.5/8Figure2.5i0.5j
foreach i/j in 1.5/9,2.5/10Figure.5.5ij
Figure2.5.51.511
Figure.51.52.512
foreach i/j in 1.5/13,2.5/14Figurei.52.5j
Figure2.51.52.515
foreach i/j in 1.5/16,2.5/17Figure.52.5ij
Figure1.52.52.518
foreach i/j in 1.5/19,2.5/20Figure2.52.5ij
psSolid[object=fusion,
base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
composeSolid
endpspicture
enddocument

For a lot of cubes you can simplify the fusion object:
defcubes
multidoiA=1+120xdefcubescubesspace ciA
beginpspicture ....
....
psSolid[object=fusion, base=cubes]
....
and here is a way how you can build the complete cube:
documentclass[pstricks]standalone
usepackagepst-solides3d
newcounterfig
defFigure#1#2#3%
stepcounterfig%
psSolid[object=cube,name=cthefig,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-5,-3.5)(4,6)
pssetDecran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory
multidoiA=0+17%
multidoiB=0+17%
multidoiC=0+17%
FigureiBiAiC%
%
psSolid[object=fusion, base=
% 1
c1 c2 c3 c4 c5 c6 c7
c8 c10 c11 c12 c14
c15 c16 c17 c18 c19 c20 c21
c22 c23 c24 c26 c27 c28
c29 c30 c31 c32 c33 c34 c35
c36 c38 c39 c40 c42
c43 c44 c45 c46 c47 c48 c49
% 2
c50 c52 c53 c54 c56
%
c64 c66 c67 c68 c70
c71 c73 c75 c77
c78 c80 c81 c82 c84
%
c92 c94 c95 c96 c98
% 3 ...
]
composeSolid
endpspicture
enddocument

and the complete image:

Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
|
show 1 more comment
If you do not want the inside also with cubes, it is simple:
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 60 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
beginpspicture(-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
rm= 8 12 24 36 40
57 61 73 85 89
106 110 122 134 138
155 159 171 183 187
208 212 220 228 232
269 273 281 289 293,
hollow,incolor=blue!30]%
endpspicture
enddocument

And as single cubes:
documentclass[pstricks]standalone
usepackagepst-solides3d
defFigure#1#2#3#4%
psSolid[object=cube,name=c#4,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory
foreach i/j in 0.5/1,1.5/2,2.5/3Figure0.5i0.5j
foreach i/j in 1.5/4,2.5/5Figurei.50.5j
Figure1.52.50.56
foreach i/j in 1.5/7,2.5/8Figure2.5i0.5j
foreach i/j in 1.5/9,2.5/10Figure.5.5ij
Figure2.5.51.511
Figure.51.52.512
foreach i/j in 1.5/13,2.5/14Figurei.52.5j
Figure2.51.52.515
foreach i/j in 1.5/16,2.5/17Figure.52.5ij
Figure1.52.52.518
foreach i/j in 1.5/19,2.5/20Figure2.52.5ij
psSolid[object=fusion,
base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
composeSolid
endpspicture
enddocument

For a lot of cubes you can simplify the fusion object:
defcubes
multidoiA=1+120xdefcubescubesspace ciA
beginpspicture ....
....
psSolid[object=fusion, base=cubes]
....
and here is a way how you can build the complete cube:
documentclass[pstricks]standalone
usepackagepst-solides3d
newcounterfig
defFigure#1#2#3%
stepcounterfig%
psSolid[object=cube,name=cthefig,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-5,-3.5)(4,6)
pssetDecran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory
multidoiA=0+17%
multidoiB=0+17%
multidoiC=0+17%
FigureiBiAiC%
%
psSolid[object=fusion, base=
% 1
c1 c2 c3 c4 c5 c6 c7
c8 c10 c11 c12 c14
c15 c16 c17 c18 c19 c20 c21
c22 c23 c24 c26 c27 c28
c29 c30 c31 c32 c33 c34 c35
c36 c38 c39 c40 c42
c43 c44 c45 c46 c47 c48 c49
% 2
c50 c52 c53 c54 c56
%
c64 c66 c67 c68 c70
c71 c73 c75 c77
c78 c80 c81 c82 c84
%
c92 c94 c95 c96 c98
% 3 ...
]
composeSolid
endpspicture
enddocument

and the complete image:

If you do not want the inside also with cubes, it is simple:
documentclass[pstricks,border=10pt]standalone
usepackagepst-solides3d
begindocument
pssetviewpoint=120 60 30 rtp2xyz,Decran=50
pstVerb/Colors [(red)(yellow)(orange)(green)(blue)] def
beginpspicture(-3,-3)(3,3)
psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
rm= 8 12 24 36 40
57 61 73 85 89
106 110 122 134 138
155 159 171 183 187
208 212 220 228 232
269 273 281 289 293,
hollow,incolor=blue!30]%
endpspicture
enddocument

And as single cubes:
documentclass[pstricks]standalone
usepackagepst-solides3d
defFigure#1#2#3#4%
psSolid[object=cube,name=c#4,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-4.5,-3.5)(6,6)
pssetDecran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory
foreach i/j in 0.5/1,1.5/2,2.5/3Figure0.5i0.5j
foreach i/j in 1.5/4,2.5/5Figurei.50.5j
Figure1.52.50.56
foreach i/j in 1.5/7,2.5/8Figure2.5i0.5j
foreach i/j in 1.5/9,2.5/10Figure.5.5ij
Figure2.5.51.511
Figure.51.52.512
foreach i/j in 1.5/13,2.5/14Figurei.52.5j
Figure2.51.52.515
foreach i/j in 1.5/16,2.5/17Figure.52.5ij
Figure1.52.52.518
foreach i/j in 1.5/19,2.5/20Figure2.52.5ij
psSolid[object=fusion,
base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
composeSolid
endpspicture
enddocument

For a lot of cubes you can simplify the fusion object:
defcubes
multidoiA=1+120xdefcubescubesspace ciA
beginpspicture ....
....
psSolid[object=fusion, base=cubes]
....
and here is a way how you can build the complete cube:
documentclass[pstricks]standalone
usepackagepst-solides3d
newcounterfig
defFigure#1#2#3%
stepcounterfig%
psSolid[object=cube,name=cthefig,ngrid=1,a=1,
action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)
begindocument
beginpspicture(-5,-3.5)(4,6)
pssetDecran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory
multidoiA=0+17%
multidoiB=0+17%
multidoiC=0+17%
FigureiBiAiC%
%
psSolid[object=fusion, base=
% 1
c1 c2 c3 c4 c5 c6 c7
c8 c10 c11 c12 c14
c15 c16 c17 c18 c19 c20 c21
c22 c23 c24 c26 c27 c28
c29 c30 c31 c32 c33 c34 c35
c36 c38 c39 c40 c42
c43 c44 c45 c46 c47 c48 c49
% 2
c50 c52 c53 c54 c56
%
c64 c66 c67 c68 c70
c71 c73 c75 c77
c78 c80 c81 c82 c84
%
c92 c94 c95 c96 c98
% 3 ...
]
composeSolid
endpspicture
enddocument

and the complete image:

edited Mar 12 at 11:12
answered Mar 11 at 18:07
HerbertHerbert
276k25419732
276k25419732
Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
|
show 1 more comment
Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
Yes, I see. Thanks.
– chishimutoji
Mar 12 at 6:56
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
see edited answer for simplifying the list of cubes
– Herbert
Mar 12 at 7:28
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
+1: Pstricks is not dead yet :)
– Dr. Manuel Kuehner
Mar 12 at 7:32
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
With your animation, you change viewpoint or Rot?=... ?
– chishimutoji
Mar 12 at 12:37
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
' viewpoint=80 iDspace 10 rtp2xyz'
– Herbert
Mar 12 at 12:51
|
show 1 more comment
Something like this?
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrarycalc
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
unit xy plane/.style=plane=#1(1,0,0)(0,1,0),
unit xz plane/.style=plane=#1(1,0,0)(0,0,1),
unit yz plane/.style=plane=#1(0,1,0)(0,0,1),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/unit cube/.style=code=
path[get projections];
draw (0,0,0) -- (1,1,1);
ifnumzproj=-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,0)];
fi
ifnumyproj=1
path[3d cube/every face,3d cube/yz face,unit yz plane=(1,0,0)];
else
path[3d cube/every face,3d cube/yz face,unit yz plane=(0,0,0)];
fi
ifnumxproj=1
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,0,0)];
else
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,1,0)];
fi
ifnumzproj>-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,1)];
fi
,
3d cube/.cd,
xy face/.style=fill=orange,
xz face/.style=fill=blue,
yz face/.style=fill=red,
every face/.style=draw,very thick
begindocument
foreach Angle in 5,15,...,355
tdplotsetmaincoords60Angle % the first argument cannot be larger than 90
begintikzpicture[line join=round]
pgfmathtruncatemacroNumCubes7
path[use as bounding box] (-NumCubes/2-3,-NumCubes/2-2)
rectangle (NumCubes/2+3,NumCubes/2+4);
beginscope[tdplot_main_coords]
pgfmathtruncatemacroNextToLastNumCubes-1
path[get projections];
ifnumyproj=1
defLstX1,...,NumCubes
else
defLstXNumCubes,NextToLast,...,1
fi
ifnumxproj=-1
defLstY1,...,NumCubes
else
defLstYNumCubes,NextToLast,...,1
fi
ifnumzproj=1
defLstZ1,...,NumCubes
else
defLstZNumCubes,NextToLast,...,1
fi
foreach X in LstX
foreach Y in LstY
foreach Z in LstZ
xdefitest1
ifoddX
else
pgfmathtruncatemacrojtestmod(X+Y,4)
ifnumjtest=0
xdefitest0
fi
pgfmathtruncatemacrojtestmod(X+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifoddY
else
pgfmathtruncatemacrojtestmod(Y+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifnumitest=1
path (X-NumCubes/2-1/2,Y-NumCubes/2-1/2,Z-NumCubes/2-1/2) picunit cube;
fi
endscope
endtikzpicture
enddocument

2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
add a comment |
Something like this?
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrarycalc
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
unit xy plane/.style=plane=#1(1,0,0)(0,1,0),
unit xz plane/.style=plane=#1(1,0,0)(0,0,1),
unit yz plane/.style=plane=#1(0,1,0)(0,0,1),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/unit cube/.style=code=
path[get projections];
draw (0,0,0) -- (1,1,1);
ifnumzproj=-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,0)];
fi
ifnumyproj=1
path[3d cube/every face,3d cube/yz face,unit yz plane=(1,0,0)];
else
path[3d cube/every face,3d cube/yz face,unit yz plane=(0,0,0)];
fi
ifnumxproj=1
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,0,0)];
else
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,1,0)];
fi
ifnumzproj>-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,1)];
fi
,
3d cube/.cd,
xy face/.style=fill=orange,
xz face/.style=fill=blue,
yz face/.style=fill=red,
every face/.style=draw,very thick
begindocument
foreach Angle in 5,15,...,355
tdplotsetmaincoords60Angle % the first argument cannot be larger than 90
begintikzpicture[line join=round]
pgfmathtruncatemacroNumCubes7
path[use as bounding box] (-NumCubes/2-3,-NumCubes/2-2)
rectangle (NumCubes/2+3,NumCubes/2+4);
beginscope[tdplot_main_coords]
pgfmathtruncatemacroNextToLastNumCubes-1
path[get projections];
ifnumyproj=1
defLstX1,...,NumCubes
else
defLstXNumCubes,NextToLast,...,1
fi
ifnumxproj=-1
defLstY1,...,NumCubes
else
defLstYNumCubes,NextToLast,...,1
fi
ifnumzproj=1
defLstZ1,...,NumCubes
else
defLstZNumCubes,NextToLast,...,1
fi
foreach X in LstX
foreach Y in LstY
foreach Z in LstZ
xdefitest1
ifoddX
else
pgfmathtruncatemacrojtestmod(X+Y,4)
ifnumjtest=0
xdefitest0
fi
pgfmathtruncatemacrojtestmod(X+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifoddY
else
pgfmathtruncatemacrojtestmod(Y+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifnumitest=1
path (X-NumCubes/2-1/2,Y-NumCubes/2-1/2,Z-NumCubes/2-1/2) picunit cube;
fi
endscope
endtikzpicture
enddocument

2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
add a comment |
Something like this?
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrarycalc
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
unit xy plane/.style=plane=#1(1,0,0)(0,1,0),
unit xz plane/.style=plane=#1(1,0,0)(0,0,1),
unit yz plane/.style=plane=#1(0,1,0)(0,0,1),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/unit cube/.style=code=
path[get projections];
draw (0,0,0) -- (1,1,1);
ifnumzproj=-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,0)];
fi
ifnumyproj=1
path[3d cube/every face,3d cube/yz face,unit yz plane=(1,0,0)];
else
path[3d cube/every face,3d cube/yz face,unit yz plane=(0,0,0)];
fi
ifnumxproj=1
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,0,0)];
else
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,1,0)];
fi
ifnumzproj>-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,1)];
fi
,
3d cube/.cd,
xy face/.style=fill=orange,
xz face/.style=fill=blue,
yz face/.style=fill=red,
every face/.style=draw,very thick
begindocument
foreach Angle in 5,15,...,355
tdplotsetmaincoords60Angle % the first argument cannot be larger than 90
begintikzpicture[line join=round]
pgfmathtruncatemacroNumCubes7
path[use as bounding box] (-NumCubes/2-3,-NumCubes/2-2)
rectangle (NumCubes/2+3,NumCubes/2+4);
beginscope[tdplot_main_coords]
pgfmathtruncatemacroNextToLastNumCubes-1
path[get projections];
ifnumyproj=1
defLstX1,...,NumCubes
else
defLstXNumCubes,NextToLast,...,1
fi
ifnumxproj=-1
defLstY1,...,NumCubes
else
defLstYNumCubes,NextToLast,...,1
fi
ifnumzproj=1
defLstZ1,...,NumCubes
else
defLstZNumCubes,NextToLast,...,1
fi
foreach X in LstX
foreach Y in LstY
foreach Z in LstZ
xdefitest1
ifoddX
else
pgfmathtruncatemacrojtestmod(X+Y,4)
ifnumjtest=0
xdefitest0
fi
pgfmathtruncatemacrojtestmod(X+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifoddY
else
pgfmathtruncatemacrojtestmod(Y+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifnumitest=1
path (X-NumCubes/2-1/2,Y-NumCubes/2-1/2,Z-NumCubes/2-1/2) picunit cube;
fi
endscope
endtikzpicture
enddocument

Something like this?
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrarycalc
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
unit xy plane/.style=plane=#1(1,0,0)(0,1,0),
unit xz plane/.style=plane=#1(1,0,0)(0,0,1),
unit yz plane/.style=plane=#1(0,1,0)(0,0,1),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/unit cube/.style=code=
path[get projections];
draw (0,0,0) -- (1,1,1);
ifnumzproj=-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,0)];
fi
ifnumyproj=1
path[3d cube/every face,3d cube/yz face,unit yz plane=(1,0,0)];
else
path[3d cube/every face,3d cube/yz face,unit yz plane=(0,0,0)];
fi
ifnumxproj=1
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,0,0)];
else
path[3d cube/every face,3d cube/xz face,unit xz plane=(0,1,0)];
fi
ifnumzproj>-1
path[3d cube/every face,3d cube/xy face,unit xy plane=(0,0,1)];
fi
,
3d cube/.cd,
xy face/.style=fill=orange,
xz face/.style=fill=blue,
yz face/.style=fill=red,
every face/.style=draw,very thick
begindocument
foreach Angle in 5,15,...,355
tdplotsetmaincoords60Angle % the first argument cannot be larger than 90
begintikzpicture[line join=round]
pgfmathtruncatemacroNumCubes7
path[use as bounding box] (-NumCubes/2-3,-NumCubes/2-2)
rectangle (NumCubes/2+3,NumCubes/2+4);
beginscope[tdplot_main_coords]
pgfmathtruncatemacroNextToLastNumCubes-1
path[get projections];
ifnumyproj=1
defLstX1,...,NumCubes
else
defLstXNumCubes,NextToLast,...,1
fi
ifnumxproj=-1
defLstY1,...,NumCubes
else
defLstYNumCubes,NextToLast,...,1
fi
ifnumzproj=1
defLstZ1,...,NumCubes
else
defLstZNumCubes,NextToLast,...,1
fi
foreach X in LstX
foreach Y in LstY
foreach Z in LstZ
xdefitest1
ifoddX
else
pgfmathtruncatemacrojtestmod(X+Y,4)
ifnumjtest=0
xdefitest0
fi
pgfmathtruncatemacrojtestmod(X+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifoddY
else
pgfmathtruncatemacrojtestmod(Y+Z,4)
ifnumjtest=0
xdefitest0
fi
fi
ifnumitest=1
path (X-NumCubes/2-1/2,Y-NumCubes/2-1/2,Z-NumCubes/2-1/2) picunit cube;
fi
endscope
endtikzpicture
enddocument

edited Mar 12 at 6:16
answered Mar 12 at 6:05
marmotmarmot
109k5133252
109k5133252
2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
add a comment |
2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
2
2
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
(+1) Wow! It is very beautiful.
– chishimutoji
Mar 12 at 6:08
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
@chishimutoji Thanks!
– marmot
Mar 12 at 6:16
add a comment |
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%2f478922%2fhow-to-draw-a-cube-as-the-following%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
I think that there are two aspects. The first one, how to draw a cube with holes, has been discussed e.g. in tex.stackexchange.com/a/383419/121799. And then your screen shot has a perspective view. Unless you want to use
asymptoteyou might be interested in tex.stackexchange.com/a/447120/121799 if you insist on the perspective view. If not, please add the information that you are not to your question. (+1)– marmot
Mar 11 at 16:10
The only difference is that you have to place 7*49-7*35-6*5 simple squares. This can be done by using the coordinates
psSolid[object=cube,..](x,y,z). That's all– Herbert
Mar 11 at 17:27
You have to use
solidmemory, action=none,name=cubeXXXand then an objectfusion. See documentation for a lot of examples. Without theobject=fusionyou cannot have hidden surfaces.– Herbert
Mar 11 at 18:36
see extended answer
– Herbert
Mar 12 at 6:42