How to draw a sliced cube shape?

How to draw a sliced cube shape?



I am trying to draw a box, sliced into rectangles. I followed the code from here Need help creating a 3D cube from a 2D set of nodes in TikZ but latex is too difficult so i dont know how to edit the code from there


documentclass[parskip]scrartcl
usepackage[margin=15mm]geometry
usepackagetikz

begindocument
begintikzpicture
foreach x in0,...,4
draw (0,x ,4) -- (4,x ,4);
draw (x ,0,4) -- (x ,4,4);
draw (4,x ,4) -- (4,x ,0);
draw (x ,4,4) -- (x ,4,0);
draw (4,0,x ) -- (4,4,x );
draw (0,4,x ) -- (4,4,x );

endtikzpicture

enddocument



Below is what Id like (edited from paint)



enter image description here




1 Answer
1



This is a version which is very close to your MWE. There are arguably more elegant ways of doing this with the 3d library and/or tikz-3dplot.


documentclass[parskip]scrartcl
usepackage[margin=15mm]geometry
usepackagetikz

begindocument
begintikzpicture
foreach x in0,...,4
draw (0,x ,4) -- (4,x ,4);
ifnumx=0
draw (x ,0,4) -- (x ,4,4);
else
draw (x ,0,4) -- (x ,0.1,4) (x ,0.9,4) -- (x ,1.1,4)
(x ,1.9,4) -- (x ,2.1,4) (x ,2.9,4) -- (x ,3.1,4)
(x ,3.9,4) -- (x ,4,4);
fi
draw (4,x ,4) -- (4,x ,0);
ifnumx=0
draw (x ,4,4) -- (x ,4,0);
else
draw (x,4,0) -- (x,4,0.1) (x,4,0.9) -- (x,4,1.1)
(x,4,1.9) -- (x,4,2.1) (x,4,2.9) -- (x,4,3.1)
(x,4,3.9) -- (x,4,4);
fi
draw (4,0,x ) -- (4,4,x );
draw (0,4,x ) -- (4,4,x );

endtikzpicture
enddocument



enter image description here






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)