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.

6
  • 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, 2023 at 6:37
  • See tex.stackexchange.com/questions/12020/…. 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, 2023 at 6:43
  • Possible duplicate: 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, 2023 at 6:53
  • @cfr: that is no duplicate ...
    – user187802
    Nov 30, 2023 at 9:28
  • Take a look at this package tikz3d-fr (documentation in french)
    – pascal974
    Nov 30, 2023 at 13:48

1 Answer 1

1

Run with lualatex

\DocumentMetadata{}
\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}
    
\begin{pspicture}[solidmemory](-5,-4)(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)
 \axesIIID[showOrigin=false](3,3,5)(4,4,6)
\end{pspicture}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .