Draw a path in a surface with tikz/pgf

pgfplotstikz-pgf

Is possible to draw a "random" path in a surface like those Callen's graph? Have a library on tikz to do this?

Like draw a surface with tikz-3dplot and draw a line, or a curve, in this surface.

Example:
enter image description here

Best Answer

\documentclass[tikz,border=1 cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{patchplots} 
\begin{document}
\begin{tikzpicture}[declare function={%
f(\x,\y)=100-(\x-20)^2-(\y)^2;
rndx(\t,\random)=21+\random+2*sin(720*\t)+\random;
rndy(\t,\random)=9.3-7*\t;
}]
\begin{axis}[
  view={50}{30},
  colormap/cool,
  axis lines=center,
  xmin=0, xmax=50,
  ymin=0, ymax=30,
  zmin=0, zmax=120,
  y dir=reverse,
  ticks=none,
  ]
\addplot3[
    mesh, patch refines=1,
    domain=9:31, samples=17,
    domain y=0:10, samples y=11,
    z filter/.expression={z<-15?nan:z}, unbounded coords=jump,
    ultra thin,
] {(f(x,y)};
\addplot3[densely dashed, domain=20:10,samples y=1, smooth]  {(f(x,0)};
\addplot3[domain=20:30, samples y=1, smooth]  {(f(x,0)};
\addplot3[densely dashed, variable=\t, domain=-90:-30, smooth, samples y=1]  ({10*sin(t)+20}, {10*cos(t)}, 0);
\addplot3[variable=\t, domain=-30:90, smooth, samples y=1]  ({10*sin(t)+20}, {10*cos(t)}, 0);
\addplot3[variable=\t, domain=0:10,  samples y=1]  ({20+t*sin(-30)},{t*cos(-30)},{f({20+t*sin(-30)},{t*cos(-30)})});
\addplot3[red,     variable=\t, domain=0:1, samples=30,  samples y=1, point meta=rnd]  ( {rndx(t,meta)}, {rndy(t,meta)}, {f({rndx(t,meta)}, {rndy(t,meta)})} );
\addplot3[magenta, variable=\t, domain=0:1, samples=30,  samples y=1, point meta=rnd]  ( {rndx(t,meta)}, {rndy(t,meta)}, {f({rndx(t,meta)}, {rndy(t,meta)})} );
\addplot3[blue,    variable=\t, domain=0:1, samples=30,  samples y=1, point meta=rnd]  ( {rndx(t,meta)}, {rndy(t,meta)}, {f({rndx(t,meta)}, {rndy(t,meta)})} );
\end{axis}
\end{tikzpicture}
\end{document}

Paraboloid with three random paths