Eu tenho o seguinte código para desenhar uma superfície usando tikz-3d
:
\documentclass{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[tdplot_main_coords]
% restore these if you want to see where the axes point
\draw[thick,-latex] (0,0,0) coordinate(O) -- (3.5,0,0) node[anchor=north east] (x) {$x$};
\draw[thick,-latex] (0,0,0) -- (0,3.5,0) node[anchor=north west] (y) {$y$};
\draw[thick,-latex] (0,0,0) -- (0,0,2.5) node[anchor=south] (z) {$z$};
\draw[thick,dashed] (0,0,0) coordinate(O) -- (-1,0,0);
\draw[thick,dashed] (0,0,0) -- (0,-1,0);
\draw[thick,dashed] (0,0,0) -- (0,0,-0.5);
\foreach \t in {-1,-0.95,...,1}{
\draw[red,opacity=0.5] plot[domain={-sqrt(-\t*\t + 1)}:{sqrt(-\t*\t + 1)},samples=100,smooth] ({\t},{\x},{1-\t*\t-\x*\x});
}
\foreach \t in {-1,-0.95,...,1}{
\draw[red,draw opacity=0.5] plot[domain={-sqrt(-\t*\t + 1)}:{sqrt(-\t*\t + 1)},samples=100,smooth] ({\x},{\t},{1-\t*\t-\x*\x});
}
\draw[red,draw opacity=0.5] plot[domain={0}:{2*pi},samples=100,smooth] ({cos(deg(\x))},{sin(deg(\x))},{0});
\end{tikzpicture}
\end{document}
cuja saída é a seguinte:
Existe uma maneira de traçar a parte desta superfície acima de uma determinada região não retangular do plano xy? Por exemplo, se eu quiser a parte do parabolóide acima do triângulo 0 <=x <=1 e 0<=y <=x?
Responder1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={120}{10},
xmin=-2, xmax=2,
ymin=-2, ymax=2,
zmin=-0.5, zmax=1,
axis equal, axis lines=center,
xtick=\empty, ytick=\empty, ztick=\empty,
]
\addplot3[
mesh, red,
domain=-1:1, samples=40,
y domain=-1:1, samples y=40,
x filter/.expression={0<=x&&x<=1?x:nan},
y filter/.expression={0<=y&&y<=x?y:nan},
unbounded coords=jump,
] (x,y,{1-x^2-y^2});
\addplot3[
red, forget plot,
domain=0:1, samples=20,
samples y=1,
variable=t,
] (t,t,{1-t^2-t^2});
\addplot3[
red, forget plot,
domain=0:1, samples=20,
samples y=1,
variable=t,
] (1,t,{1-1^2-t^2});
\end{axis}
\end{tikzpicture}
\end{document}