[Tex/LaTex] Drawing Solids with LaTeX

3dasymptotepackages

I want to know if there is a package that automatically draw solids (spheres, cylinders, cubes, prisms).

I know I can do this kind of drawing using TikZ or PSTricks. But what about a package where you can type \cube{2cm} and it draws a cube of side 2 cm.

I am not posting a MWE because I just want to know if such package exists.

Best Answer

There is pst-solides3d. The package readme mentions:

The pack­age is de­signed to draw solids in 3D per­spec­tive. Fea­tures in­clude:

  • cre­ate prim­i­tive solids;

  • cre­ate solids by in­clud­ing a list of its ver­tices and faces;

  • faces of solids and sur­faces can be col­ored by choos­ing from a very large palette of col­ors;

  • draw para­met­ric sur­faces in al­ge­braic and re­verse pol­ish no­ta­tion;

  • cre­ate ex­plicit and pa­ram­e­ter­ized al­ge­braic func­tions drawn in 2 or 3 di­men­sions;

  • project text onto a plane and onto the faces of a solid;

  • sup­port for in­clud­ing ex­ter­nal database files.

Here's a small example (compile with LaTeX or XeLaTeX):

enter image description here

\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\rule[-1cm]{2cm}{2cm} \qquad\qquad
%
\psset{viewpoint=100 30 20,Decran=100,unit=1cm}
\psSolid[object=cube,a=2,
  action=draw*,
  fillcolor=magenta!20]
\end{document}