1

I am trying to recreate this diagram in a standalone PDF using TikZ or PSTricks. enter image description here

Two extra requirements:

  • I have to be able to alter the viewing angle arbitrarily
  • I want to use relative coordinates rather than hard-coding the absolute coordinates of every cube. I'd like to be able to define cubes relative to nearby cubes using nodes since it will be easy to generalise this code to other shapes.

I'm fairly experienced with TikZ, but just looking for a more elegant solution.

  • 3
    Welcome! A more elegant solution than what? Please share the code you have. If you are serious about the first requirement, forget doing this with TikZ. You need something which works in 3 dimensions - not something which fakes 3 in 2 dimensions. If you change the viewing angle, you have to rewrite the code. There are tools to do some of the calculations, but you still have to deal with things like the order in which things are drawn and which bits need drawing. Please clarify the second requirement. – cfr Nov 30 '23 at 06:37
  • See https://tex.stackexchange.com/questions/12020/what-is-the-easiest-way-to-draw-a-3d-cube-with-tikz?noredirect=1&lq=1. Note one of the answers there is a 'list' answer pointing to relevant answers to other questions. (Currently listed second, with the highest score.) – cfr Nov 30 '23 at 06:43
  • Possible duplicate: https://tex.stackexchange.com/q/29877/. I don't know if the answer(s) there became packages but, if not, it's a shame. – cfr Nov 30 '23 at 06:53
  • @cfr: that is no duplicate ... – user187802 Nov 30 '23 at 09:28
  • Take a look at this package tikz3d-fr (documentation in french) – pascal974 Nov 30 '23 at 13:48
  • @user187802 It was a suggestion only. The answers are the best code I'm aware of for something like this in PGF/TikZ and probably the best basis for this kind of diagram. Given how vague the second requirement is and how unobtainable the first, I don't think the suggestion unreasonable. (Note that I didn't vote to mark it as a duplicate.) – cfr Nov 30 '23 at 16:52

1 Answers1

1

Run with lualatex

\DocumentMetadata{}
\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}

\begin{pspicture}solidmemory(5,7) \psset{Decran=15,viewpoint=10 10 7,object=cube,a=2,action=draw**,fillcolor=magenta!20} \psSolid(0,0,0)\psSolid(0,0,2)\psSolid(0,0,4) \psSolid(2,0,0) \psSolid(0,2,0) \psSolid(0,2,2) \axesIIIDshowOrigin=false(4,4,6) \end{pspicture}

\end{document}

enter image description here

user187802
  • 16,850