在非矩形域中绘制曲面

在非矩形域中绘制曲面

我有以下代码来使用绘制表面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} 

其输出如下:

在此处输入图片描述

有没有办法绘制该曲面在 xy 平面上给定非矩形区域上方的部分?例如,如果我想要三角形 0 <=x <=1 和 0<=y <=x 上方的抛物面部分?

答案1

\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}

三角形域上的抛物面网格

相关内容