我有输出多个抛物线的代码
\begin{document}
\tdplotsetmaincoords{70}{20}
\begin{tikzpicture}[tdplot_main_coords,
declare function={pX=2;}]
\begin{scope}[canvas is yz plane at x=0]
\draw (-pX,-pX) coordinate (bl1) -- (pX,-pX) coordinate (br1)
-- (pX,pX) coordinate (tr1) -- (-pX,pX) coordinate (tl1) -- cycle;
\draw[stealth-stealth] (0,pX) node[below left]{$x_2$}
-- (0,0) -- (pX,0) node[below left]{$x_1$};
\pgflowlevelsynccm
%\draw[-{Latex[bend]}] (2,0) arc(0:380:1);
%\draw[-{Latex[bend]}] (0,-1) arc(-90:290:1);
%\draw[-{Latex[bend]}] (0,0) arc(-90:380:1);
\end{scope}
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X1) -- ++ (1,0,0);}
%
\draw (0,0,0) -- (4,0,0);
% plane
\fill[gray,fill opacity=0.3] (-1,-4,0) -- (7,-4,0) --
(7,4,0) -- (-1,4,0) -- cycle;
\begin{scope}[canvas is yz plane at x=4]
\draw (-pX,-pX) coordinate (bl2) -- (pX,-pX) coordinate (br2)
-- (pX,pX) coordinate (tr2) -- (-pX,pX) coordinate (tl2) -- cycle;
\draw[stealth-stealth] (0,pX) -- (0,0) -- (pX,0);
\pgflowlevelsynccm
%\draw[-{Latex[bend]}] (1,0) arc(0:380:0.25);
%\draw[-{Latex[bend]}] (0,-0.25) arc(-90:290:0.25);
%\draw[-{Latex[bend]}] (0,0.25) arc(-90:380:0.25);
\end{scope}
\draw[-latex] (4,0,0) -- (6,0,0) node[below left]{$x_3$};
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X2) -- ++ (1,0,0);}
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}
\clip (0,-2) rectangle (4,3);
\foreach \X in {-2,-1.6,...,2}
{\draw (0,\X) parabola ++(5,1);}
\end{scope}
% \draw[-stealth] (-1,0) -- (5,0) node[below right]{$x_3$};
% \draw[-stealth] (0,-0.5) node[above left]{$0$} -- (0,3)
% node[right=2em,yshift=-1em]{$\theta(x_3)$};
% \draw[-stealth] (4,-0.5) node[above left]{$L$} -- (4,3) node[below right]{$x_1$};
\end{scope}
\end{tikzpicture}
\end{document}
我正在尝试用一系列这样的线来代替抛物线 从而制作一系列图层,每层都有随机箭头方向。这可以在 tikz 中完成吗?提前致谢。
答案1
这会添加随机箭头。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{20}
\begin{tikzpicture}[tdplot_main_coords,
declare function={pX=2;}]
\begin{scope}[canvas is yz plane at x=0]
\draw (-pX,-pX) coordinate (bl1) -- (pX,-pX) coordinate (br1)
-- (pX,pX) coordinate (tr1) -- (-pX,pX) coordinate (tl1) -- cycle;
\draw[stealth-stealth] (0,pX) node[below left]{$x_2$}
-- (0,0) -- (pX,0) node[below left]{$x_1$};
\pgflowlevelsynccm
\end{scope}
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X1) -- ++ (1,0,0);}
%
\draw (0,0,0) -- (4,0,0);
% plane
\fill[gray,fill opacity=0.3] (-1,-4,0) -- (7,-4,0) --
(7,4,0) -- (-1,4,0) -- cycle;
\begin{scope}[canvas is yz plane at x=4]
\draw (-pX,-pX) coordinate (bl2) -- (pX,-pX) coordinate (br2)
-- (pX,pX) coordinate (tr2) -- (-pX,pX) coordinate (tl2) -- cycle;
\draw[stealth-stealth] (0,pX) -- (0,0) -- (pX,0);
\end{scope}
\draw[-latex] (4,0,0) -- (6,0,0) node[below left]{$x_3$};
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X2) -- ++ (1,0,0);}
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}
\clip (0,-2) rectangle (4,3);
\foreach \X in {0.25,0.75,...,2.75}
{\pgfmathsetmacro{\myrnd}{rnd*360}
\foreach \Y in {-1.75,-1.25,...,1.75}
{
\draw[-stealth] ({\X-0.2*cos(\myrnd)},{\Y-0.2*sin(\myrnd)}) --
({\X+0.2*cos(\myrnd)},{\Y+0.2*sin(\myrnd)});
}
\draw[densely dashed] (\X+0.25,-2) -- (\X+0.25,2);}
% \foreach \X in {-2,-1.6,...,2}
% {\draw (0,\X) parabola ++(5,1);}
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
或者
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{20}
\begin{tikzpicture}[tdplot_main_coords,
declare function={pX=2;}]
\begin{scope}[canvas is yz plane at x=0]
\draw (-pX,-pX) coordinate (bl1) -- (pX,-pX) coordinate (br1)
-- (pX,pX) coordinate (tr1) -- (-pX,pX) coordinate (tl1) -- cycle;
\draw[stealth-stealth] (0,pX) node[below left]{$x_2$}
-- (0,0) -- (pX,0) node[below left]{$x_1$};
\pgflowlevelsynccm
\end{scope}
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X1) -- ++ (1,0,0);}
%
\draw (0,0,0) -- (4,0,0);
% plane
\fill[gray,fill opacity=0.3] (-1,-4,0) -- (7,-4,0) --
(7,4,0) -- (-1,4,0) -- cycle;
\begin{scope}[canvas is yz plane at x=4]
\draw (-pX,-pX) coordinate (bl2) -- (pX,-pX) coordinate (br2)
-- (pX,pX) coordinate (tr2) -- (-pX,pX) coordinate (tl2) -- cycle;
\draw[stealth-stealth] (0,pX) -- (0,0) -- (pX,0);
\end{scope}
\draw[-latex] (4,0,0) -- (6,0,0) node[below left]{$x_3$};
\foreach \X in {bl,tl,br,tr}
{\draw[-latex] (\X2) -- ++ (1,0,0);}
\foreach \Z in {0,0.5,...,2}
{\begin{scope}[canvas is xy plane at z=\Z]
\begin{scope}
\foreach \X in {0.25,0.75,...,2.75}
{\pgfmathsetmacro{\myrnd}{rnd*360}
\foreach \Y in {-1.75,-1.25,...,1.75}
{
\draw[-stealth] ({\X-0.2*cos(\myrnd)},{\Y-0.2*sin(\myrnd)}) --
({\X+0.2*cos(\myrnd)},{\Y+0.2*sin(\myrnd)});
}
\draw[densely dashed] (\X+0.25,-2) -- (\X+0.25,2);}
% \foreach \X in {-2,-1.6,...,2}
% {\draw (0,\X) parabola ++(5,1);}
\end{scope}
\end{scope}}
\end{tikzpicture}
\end{document}