Ich frage mich, ob es eine einfache Möglichkeit gibt, eine 3D-Funktion zu zeichnen, die über einer Menge (ihrer Domäne) definiert ist. Die Domäne soll „flach“ auf dem Boden liegend gezeichnet werden, und die Funktion soll „schwebend“ über der Domäne gezeichnet werden. Ich denke an zwei Beispiele unten:
Beachten Sie, dass die Funktion und die Domäne konvex sind (wenn Sie mit dem Konzept vertraut sind, bedeutet dies, dass Sie davon ausgehen können, dass die Menge „kartoffelförmig“ und die Funktion „schüsselförmig“ ist).
Antwort1
Sicher. Hier ist ein Beispiel. Wenn Sie mit kompilieren, lualatex
ist die Kompilierung schneller.
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=1+\x*\x+\y*\y;}]
\matrix[column sep=3em]{
\begin{axis}[hide axis,domain=0:1,domain y=0:360,smooth,samples=25,samples y=61]
\addplot3[surf,shader=flat] ({x*cos(y)},{0.8*x*sin(y)},{0});
\addplot3[surf,shader=interp,z buffer=sort] ({x*cos(y)},{0.8*x*sin(y)},{f(x*cos(y),0.8*x*sin(y))});
\end{axis}
&
\begin{axis}[hide axis,domain=0:1,domain y=0:360,smooth,samples=25,samples y=61]
\addplot3[surf,shader=flat] ({x*cos(y)*(2+sin(3*y))},{0.8*x*sin(y)*(2+sin(3*y)},{0});
\addplot3[surf,shader=interp,z buffer=sort] ({x*cos(y)*(2+sin(3*y)},{0.8*x*sin(y)*(2+sin(3*y)},{f(x*cos(y),0.8*x*sin(y))});
\end{axis}\\
};
\end{tikzpicture}
\end{document}
Oder mit einer dreieckigen Domäne.
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=1+\x*\x+\y*\y;}]
\matrix[column sep=3em]{
\begin{axis}[hide axis,domain=0:1,domain y=0:360,smooth,samples=25,samples y=61,
declare function={myx(\x,\y)=\x*cos(\y);myy(\x,\y)=\x*sin(\y);}]
\addplot3[surf,shader=flat] ({myx(x,y)},{myy(x,y)},{0});
\addplot3[surf,shader=interp,z buffer=sort]
({myx(x,y)},{myy(x,y)},{f(myx(x,y),myy(x,y))});
\end{axis}
&
\begin{axis}[hide axis,domain=-1:1,domain y=0:1,samples=25,samples y=61,
declare function={myx(\x,\y)=\x;myy(\x,\y)=\y*(1-abs(\x));}]
\addplot3[surf,shader=flat] ({myx(x,y)},{myy(x,y)},{0});
\addplot3[surf,shader=interp,z buffer=sort]
({myx(x,y)},{myy(x,y)},{f(myx(x,y),myy(x,y))});
\end{axis}\\
};
\end{tikzpicture}
\end{document}
Beachten Sie, dass Sie auch Filter verwenden können, die Grenzen dann jedoch insgesamt etwas pixelig aussehen.