我做了以下 MFW 来教授微积分中的旋转体积概念。我从以下开始:
\documentclass[a4paper,openany,12pt]{article}
\usepackage{pgf,tikz}
\usepackage{pgfplots,relsize}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines = middle, smooth, xlabel=$x$,ylabel=$y$, xmax=4, xmin=-4, ymax=3, ymin=-3]
\addplot [name path=A, line width=1pt, black, domain=0:pi] ({3*cos(deg(x))},{2*sin(deg(x))});
\addplot [name path=B, thin, black, domain=-3:3] {0};
\addplot [ thin, black, domain=0:2] ({0},{x});
\addplot [gray!20] fill between [of=A and B];
\end{axis}
\pgftext[base,x=1cm,y=5.1cm,rotate=0] {\small{$f(x)=2\sqrt{1-\frac{x^2}{9}$}}};
\end{tikzpicture}
\end{documents}
表示函数下方的平面将绕x
轴旋转,然后将显示以下内容:
\documentclass[a4paper,openany,12pt]{article}
\usepackage{pgf,tikz}
\usepackage{pgfplots,relsize}
\usepgfplotslibrary{patchplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[ view={15}{30},grid=major]
\addplot3[fill opacity=0.25,
surf,
samples=25,shader=interp,
domain=0:6,y domain=0:6,
z buffer=sort]
({5*cos(deg(x))*sin(deg(y))},{3*sin(deg(x))*sin(deg(y))},{2*cos(deg(y)) });
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
来说明旋转形成的体积。我可以做函数曲线及其下方阴影区域能否同时在 3d 图中显示?请参见下图。我对 Maple 的另一个函数进行了此操作(这只是一个示例):
我编写了参数形式的代码({3*cos(x)},{0},{2*sin(x)})
,但正如我所料,它失败了。似乎曲线没有正确地拟合到椭圆体上。谢谢任何提示!
答案1
\documentclass[a4paper,12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[ view={-15}{30},grid=major]
\addplot3[%fill opacity=0.25,
surf,samples=25,shader=interp,
domain=0:pi/3,y domain=0:2*pi,
z buffer=sort]
({x},{cos(deg(x))*sin(deg(y))},{cos(deg(x))*cos(deg(y))});
\addplot3[samples=25,blue,thick,
domain=0:pi/3,samples y=0,
z buffer=sort]
({x},{cos(deg(x))*sin(deg(50))},{cos(deg(x))*cos(deg(50))});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}