TikZ-PGF – How to Draw a Paraboloid and Its Contours in TikZ

3dtikz-pgf

I have two similar images in which paraboloid and its contours are drawn.

paraboloid1

paraboloid2

What I've ever tried is in the following code that is very different from the figure.

\documentclass{standalone}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{arrows.meta}
\tikzset{reverseclip/.style={insert path={(current bounding box.north
    east) rectangle (current bounding box.south west)}}}
\begin{document}
\tdplotsetmaincoords{120}{-25}
\begin{tikzpicture}[tdplot_main_coords]
\draw [thick] (0,0,0) -- (4,0,0) node {y} (0,0,0) -- (0,4,0) node {x} (0,0,0) -- (0,0,10) node {z};
\tdplotsetrotatedcoords{0}{0}{-25}
\draw [red, thick, tdplot_rotated_coords] (0,0,0) -- (4,0,0) node {y} (0,0,0) -- (0,4,0) node {x} (0,0,0) -- (0,0,10) node {z};
\fill [cyan, tdplot_rotated_coords, canvas is xy plane at z=0, opacity=0.67] (0,0) circle [radius=3];
\fill [cyan, tdplot_rotated_coords, canvas is xz plane at y=0, opacity=0.67] plot [variable=\x, domain=-3:3, samples=50] ({\x},{9-\x*\x});
\foreach \r in {1,2,3}
\draw [red, very thick, canvas is xy plane at z=0] (0,0) circle [radius=\r];
\node [below] at (0,3,0) {10};
\node [below] at (3,0,0) {10};
\node [left] at (0,0,9) {100};

\begin{scope}
\clip [canvas is xy plane at z=6] (0,0) circle [radius={sqrt(3)}] [reverseclip];
\fill [orange, canvas is xy plane at z=6] (-4,-4) rectangle (4,4);
\end{scope}
\end{tikzpicture}
\end{document}

How to draw more realistic figure?

Best Answer

Why not using pgfplots; something like that:

enter image description here

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$, ylabel=$y$, zlabel=$z$, 
xmin=-19, xmax=19,
ymin=-19, ymax=19,
zmin=-1, zmax=110,
x={(-0.125cm,-0.05cm)}, y={(0.125cm,-0.05cm)}, z={(0cm,0.05cm)},
axis lines=middle,
every axis x label/.style={  at={(ticklabel* cs:1.05)},  },
every axis y label/.style={  at={(ticklabel* cs:1.05)},  },
every axis z label/.style={  at={(ticklabel* cs:1.05)},  },
]
% Paraboloid
\addplot3[surf,
shader=flat, draw=lightgray, fill=green, ultra thin, 
left color=green, right color=green, middle color=green!25, 
opacity=0.5, fill opacity=0.5,
data cs=polar, domain=0:360, 
y domain=0:10,
restrict z to domain=0:101, 
](x, y, 100-y^2);

% Plane 
\addplot3[surf, shader=faceted,
color=orange, 
opacity=0.01, fill opacity=0.4, 
domain=-10:10, 
](x,y,75);

% Circle at plane
\addplot3[red, smooth, 
domain=0:360, variable=\t
]({5*cos(\t)},{5*sin(\t)},{75});

% Circles at xy-plane
\pgfplotsinvokeforeach{10, 7, 2.5}{%%
\pgfmathsetmacro\Radius{#1}
\addplot3[red, smooth, 
%no markers,
%samples=55,% samples y=0, 
domain=0:360, variable=\t
]({\Radius*cos(\t)},{\Radius*sin(\t)},{0});
}%%

% Annotations 1/2
\coordinate[label=](A) at ({7*cos(135)},{7*sin(135)},{0});
\coordinate[label=](B) at (8, -8, 75);
\coordinate[label=](C) at (-4, 5, 40);
\coordinate[label=](D) at({5*cos(300)},{5*sin(300)},{75});
\end{axis}

% Annotations 2/2
\draw[semithick] (A) -- +(45:2) node[right, align=left]{
$f(x,y)=51$\\ (a typical\\ level curve in\\ the function's\\ domain)};

\draw[semithick] (B) -- +(135:0.75) node[above, align=left]{
Plane $z=75$};

\draw[semithick] (C) -- +(45:3) node[above]{$z=100-x^2-y^2$};

\draw[semithick] (D) -- +(122:2.5) node[above, align=left, xshift=2cm]{The contour curve $f(x,y)=100-x^2-y^2=75$ \\ is the circle $x^2+y^2=25$ in the plane $z=75$.};
\end{tikzpicture}   
\end{document}