如何在 TikZ 中绕指定轴旋转曲线?

如何在 TikZ 中绕指定轴旋转曲线?

我想围绕 x 轴之类的线旋转曲线。例如,我想绘制下图。可以在 TikZ 中完成这项工作吗? 图1 梅威瑟:

\documentclass[12pt, border=5mm]{standalone}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{65}{110}
\begin{tikzpicture}[tdplot_main_coords]
\draw [thick, -Stealth] (0,-1,0) -- (0,5,0) node [right] {$x$};
\draw [thick, -Stealth] (0,0,-1) -- (0,0,5) node [left] {$y$};
\draw [blue, very thick, variable=\x, domain=0.5:2, canvas is yz plane at x=0] plot ({\x},{2/\x});
\end{tikzpicture}
\end{document}

图2

答案1

用 可以绘制这样的东西pgfplots

\documentclass[12pt, border=5mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
 \begin{axis}[hide axis,width=12cm,
    zmin=-0.1,xmin=-4,xmax=4.5,zmax=5]
  \draw[thick,-Stealth] (-4,0,0) -- (4,0,0) node[pos=1.05]{$x$};
  \addplot3[surf,shader=interp,colormap/PuBu,
    domain=0:270,domain y=1:3]
   ({2*cos(x)/y},{2*sin(x)/y},y);
  \fill[blue!60,opacity=0.5] plot[domain=1:3,variable=\y] ({2/\y},0,\y) -- (0,0,3) -- (0,0,1);  
  \fill[green!60,opacity=0.5] plot[domain=1:3,variable=\y] (0,{-2/\y},\y)  -- (0,0,3) -- (0,0,1);  
  \fill[green!60,opacity=0.5] plot[domain=0:270,variable=\x]
     ({2*cos(\x)/3},{2*sin(\x)/3},3)  -- (0,0,3);
  \draw[cyan,thick] plot[domain=0.5:3.5,variable=\y,samples=32] ({2/\y},0,\y);
  \draw[thick,-Stealth] (0,0,-1) -- (0,0,5) node[pos=1.05]{$y$};
 \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容