我想制作下图的 3D 版本
我可以画出不同的矢量,但无法表示圆柱体。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,3D}
\begin{document}
\begin{tikzpicture}[x={(-0.866cm,-0.5cm)}, y={(0.866cm,-0.5cm)}, z={(0,1cm)}]
\draw[-latex] (0,0,0) coordinate(B) -- ++ (3,0,0)node[above]{$x$};
\draw[-latex](B) -- ++ (0,3,0)node[above]{$y$};
\draw[-latex](B) -- ++ (0,0,3)node[right]{$z$};
\foreach \zz in {-20,-15,-10,...,20}{
\pgfmathsetmacro{\ZZ}{\zz/10}
\begin{scope}[canvas is xy plane at z=\ZZ]
\foreach \ii in {-85,-75,...,85}{
\draw[-latex] ({cos(\ii)},{sin(\ii)}) --++ (\ii:{1*cos(\ii)});
}
\end{scope}
}
\end{tikzpicture}
\end{document}
图不太好读,必须改进!
答案1
我会使用tikz-3dplot
和reverseclip
诡计,并使箭头的长度取决于线的长度。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,arrows.meta}
% based on https://tex.stackexchange.com/a/12033/121799
\tikzset{reverseclip/.style={insert path={(current bounding box.south west)rectangle
(current bounding box.north east)} }}
\begin{document}
\tdplotsetmaincoords{60}{135}
\begin{tikzpicture}[tdplot_main_coords]
\draw[-latex] (0,0,0) coordinate(B) -- ++ (3,0,0)node[above]{$x$};
\draw[-latex](B) -- ++ (0,3,0)node[above]{$y$};
\draw[-latex](B) -- ++ (0,0,3)node[right]{$z$};
\draw ({cos(\tdplotmainphi-180)},{sin(\tdplotmainphi-180)},2) --
plot[variable=\t,domain=\tdplotmainphi-180:\tdplotmainphi,smooth,samples=51]
({cos(\t)},{sin(\t)},-2) --
plot[variable=\t,domain=\tdplotmainphi:\tdplotmainphi+360,smooth,samples=101]
({cos(\t)},{sin(\t)},2);
\pgfmathtruncatemacro{\imin}{-\tdplotmainphi+90} % helpers
\pgfmathtruncatemacro{\iminnext}{-\tdplotmainphi+100}
\pgfmathtruncatemacro{\imax}{-\tdplotmainphi+85}
\foreach \zz in {-20,-15,-10,...,20}{
\pgfmathsetmacro{\ZZ}{\zz/10}
\begin{scope}[canvas is xy plane at z=\ZZ]
\foreach \ii in {\imin,\iminnext,...,85}{
\draw[-{Latex[length={cos(\ii)*4pt}]}] ({cos(\ii)},{sin(\ii)}) --++ (\ii:{1*cos(\ii)});
}
\end{scope}
}
% clip away hidden part
\clip ({cos(\tdplotmainphi-180)},{sin(\tdplotmainphi-180)},2) --
plot[variable=\t,domain=\tdplotmainphi-180:\tdplotmainphi,smooth,samples=51]
({cos(\t)},{sin(\t)},-2) --
plot[variable=\t,domain=\tdplotmainphi:\tdplotmainphi+180,smooth,samples=101]
({cos(\t)},{sin(\t)},2) [reverseclip];
\foreach \zz in {-20,-15,-10,...,20}{
\pgfmathsetmacro{\ZZ}{\zz/10}
\begin{scope}[canvas is xy plane at z=\ZZ]
\foreach \ii in {-85,-75,...,\imax}{
\draw[-{Latex[length={cos(\ii)*4pt}]}] ({cos(\ii)},{sin(\ii)}) --++ (\ii:{1*cos(\ii)});
}
\end{scope}
}
\end{tikzpicture}
\end{document}