在非矩形域中繪製曲面

在非矩形域中繪製曲面

我有以下程式碼來使用以下命令繪製曲面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}

三角形域上的拋物面網格

相關內容