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?













15















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


enter image description here
It is hollowed inside the cube.



So, how to get the similar output to the following image?



enter image description here



%% 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


enter image description here



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



enter image description here










share|improve this question
























  • 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











  • 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















15















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


enter image description here
It is hollowed inside the cube.



So, how to get the similar output to the following image?



enter image description here



%% 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


enter image description here



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



enter image description here










share|improve this question
























  • 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











  • 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













15












15








15


4






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


enter image description here
It is hollowed inside the cube.



So, how to get the similar output to the following image?



enter image description here



%% 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


enter image description here



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



enter image description here










share|improve this question
















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


enter image description here
It is hollowed inside the cube.



So, how to get the similar output to the following image?



enter image description here



%% 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


enter image description here



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



enter image description here







pstricks pst-solides3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • 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

















  • 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











  • 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
















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










2 Answers
2






active

oldest

votes


















11














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


enter image description here



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


enter image description here



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


enter image description here



and the complete image:



enter image description here






share|improve this answer

























  • 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


















13














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


enter image description here






share|improve this answer




















  • 2





    (+1) Wow! It is very beautiful.

    – chishimutoji
    Mar 12 at 6:08











  • @chishimutoji Thanks!

    – marmot
    Mar 12 at 6:16










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
);



);













draft saved

draft discarded


















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









11














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


enter image description here



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


enter image description here



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


enter image description here



and the complete image:



enter image description here






share|improve this answer

























  • 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















11














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


enter image description here



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


enter image description here



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


enter image description here



and the complete image:



enter image description here






share|improve this answer

























  • 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













11












11








11







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


enter image description here



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


enter image description here



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


enter image description here



and the complete image:



enter image description here






share|improve this answer















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


enter image description here



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


enter image description here



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


enter image description here



and the complete image:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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











13














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


enter image description here






share|improve this answer




















  • 2





    (+1) Wow! It is very beautiful.

    – chishimutoji
    Mar 12 at 6:08











  • @chishimutoji Thanks!

    – marmot
    Mar 12 at 6:16















13














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


enter image description here






share|improve this answer




















  • 2





    (+1) Wow! It is very beautiful.

    – chishimutoji
    Mar 12 at 6:08











  • @chishimutoji Thanks!

    – marmot
    Mar 12 at 6:16













13












13








13







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


enter image description here






share|improve this answer















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


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








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












  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Moe incest case Sentencing See also References Navigation menu"'Australian Josef Fritzl' fathered four children by daughter""Small town recoils in horror at 'Australian Fritzl' incest case""Victorian rape allegations echo Fritzl case - Just In (Australian Broadcasting Corporation)""Incest father jailed for 22 years""'Australian Fritzl' sentenced to 22 years in prison for abusing daughter for three decades""RSJ v The Queen"

Who is our nearest planetary neighbor, on average?Santa Claus flies to the South PoleSeven Spheres of Unequal Mass, a weighing problem with a twistDescribe a large integerFast Mental Calculation of $7.5^7$Math in Space (without the help of celebrities)Find the value of $bigstar$: Puzzle 8 - InequalityWho drinks beer while running anyway?A Crucial DeliveryRanking And AverageHow long will my money last at roulette?

Daza language Contents Vocabulary Phonology References External links Navigation menudaza1242Daza"Dazaga"eeee178086576