Drawing surfaces with TikZ

3dgraphicsgraphstikz-pgf

As a complete TikZ novice, I want to create surfaces like the following handdrawn one with TikZ:
enter image description here

Ideally, this should be coded bottom-up: First you draw the bident with xy-plane at height 0. Then you draw a straight line at a higher height (This line is not visible in the drawing, it lies in between the height of the two purple vertices). Then you draw a bident at an even higher height. Finally, you fill in the vertical (and the thicker) lines.

I tried using code like this:

\begin{tz}[td, scale=2]

\begin{scope}[xyplane=0]
\draw (-1,0) to [bend left=15] (0.5,1) to (1.8,3);
\draw (0,-0.3) to [bend right=15] (0.5,1);
\end{scope}

\begin{scope}[xyplane=0.25*\h]
\draw(-0.5,0) to (1.4,3);
\end{scope} 

\begin{scope}[xyplane=0.5*\h]
\draw (-0.5,0) to (1.3,3);
\end{scope} 

\begin{scope}[xyplane=0.75*\h]
\draw (-1,0) to [bend left=15] (0.5,1) to (1.8,3);
\draw (0,-0.3) to [bend right=15] (0.5,1);
\end{scope}

\end{tz}

However, I am having trouble with the following:

  • draw the vertical lines
  • draw jagged lines
  • draw the curved thick lines (one in black, one in green)
  • draw the dotted edge that is hidden behind a face as dotted
  • "colour" faces by a transparent "colour"

How can I draw the above surface efficiently with TikZ? Can this be done with TikZiT?

Best Answer

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d, decorations.pathmorphing}
\begin{document}
\tdplotsetmaincoords{70}{40}
\begin{tikzpicture}[tdplot_main_coords, decoration={random steps, segment length=0.5pt, amplitude=0.3pt}, line join=round]
\coordinate (A) at (-1,0,-1);
\coordinate (B) at (-1,0,1);
\coordinate (C) at (0.8,0,1);
\coordinate (D) at (0.8,0,-1);
\path (C) +(0,-0.3,0) coordinate (Cl);
\path (C) +(0,0.3,0) coordinate (Cr);
\path (C) +(-0.8,0,0) coordinate (Cb);
\path (C) +(0,0,-0.8) coordinate (Cd);
\path (D) +(0,-0.3,0) coordinate (Dl);
\path (D) +(0,0.3,0) coordinate (Dr);
\path (D) +(-0.8,0,0) coordinate (Db);
\path (D) +(0,0,0.6) coordinate (Du);
\draw[green!70!black, ultra thick, canvas is xz plane at y=0] (Cb) to[bend right] (Cd);
\draw[ultra thick, canvas is xz plane at y=0] (Db) to[bend left] (Du);
\draw[fill=gray, fill opacity=0.5]
[canvas is xz plane at y=0] (A) -- (B) -- (Cb) to[bend right] (Cd) decorate{-- (Du)} to[bend right] (Db) -- cycle;
\draw[fill=gray, fill opacity=0.5]
{[canvas is xz plane at y=0] (Cb) to[bend right] (Cd)}
decorate{[canvas is yz plane at x=0.8] (Cd) to[bend right] (Cr)}
{[canvas is xy plane at z=1] -- (Cr) to[bend right] (Cb)};
\draw[fill=gray, fill opacity=0.5]
{[canvas is xz plane at y=0] (Db) to[bend left] (Du)}
decorate{[canvas is yz plane at x=0.8] (Du) to[bend left] (Dr)}
{[canvas is xy plane at z=-1] -- (Dr) to[bend right] (Db)};
\draw[fill=gray, fill opacity=0.5]
{[canvas is xz plane at y=0] (Cb) to[bend right] (Cd)}
decorate{[canvas is yz plane at x=0.8] (Cd) to[bend left] (Cl)}
{[canvas is xy plane at z=1] -- (Cl) to[bend left] (Cb)};
\draw[fill=gray, fill opacity=0.5]
{[canvas is xz plane at y=0, , opacity=0.5] (Db) to[bend left] (Du)}
decorate{[canvas is yz plane at x=0.8] (Du) to[bend right] (Dl)}
{[canvas is xy plane at z=-1] -- (Dl) to[bend left] (Db)};
\fill[purple!80!black] (Cd) circle[radius=1pt] (Du) circle[radius=1pt];
\end{tikzpicture}
\end{document}

3D gray surface with jagged splits