我有代码(由堆栈慷慨修正)
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,bending}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{3d}
\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]{$$}
-- (0,0) -- (pX,0) node[below left]{$$};
\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] (-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];
\end{scope}
\draw[-latex] (4,0,0) -- (5.5,0,0) node[below left]{$$};
%\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);
\draw[densely dashed] (0,-2) -- (0,2);
\foreach \X in {0.25,0.75,...,5}
{\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+.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}
输出 我想知道是否可以绘制如下所示的入射极化波,其波长等于虚线之间的间距,从最左边的矩形进入。 然后,就像波从右边的矩形开始退出一样,它有一个衰减的随机振幅,就像虚线所在的空间消耗能量并扭曲波一样。这是我想要的最终结果
在 SchrodingersCat 的帮助下,我
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,bending}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{3d}
\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]{$$}
-- (0,0) -- (pX,0) node[below left]{$$};
\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] (-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];
\end{scope}
%\draw[-latex] (4,0,0) -- (5.5,0,0) node[below left]{$$};
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}
\clip (0,-2) rectangle (4,3);
\draw[densely dashed] (0,-2) -- (0,2);
\foreach \X in {0.25,0.75,...,5}
{\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+.25,-2) -- (\X+0.25,2);}
\end{scope}
\end{scope}
%
\begin{scope}[shift={($(-4,0,0)-(0,0,0)$)}]
\begin{scope}[canvas is xy plane at z=0,dashed]
\foreach \X in {0.1,0.3,...,3.2}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{-sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{-sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thick,solid] (12.2,0) -- (12.8,0);
\end{scope}
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\foreach \X in {0.1,0.3,...,3.2}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{sin(\x*180)});
\end{scope}
\node at (1*3.5,1.75,0) {$$};
\node at (1*3.5,0,-1.25) {$$};
\end{scope}
%
\begin{scope}[shift={($(4,0,0)-(0,0,0)$)}]
\begin{scope}[canvas is xy plane at z=0,dashed]
\foreach \X in {0.4,0.6,...,3}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{-.2*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{-.2*sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thick,solid] (12.2,0) -- (12.8,0);
\end{scope}
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\foreach \X in {0.4,0.6,...,3}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{.5*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{.5*sin(\x*180)});
\end{scope}
\node at (1*3.5,1.75,0) {$$};
\node at (1*3.5,0,-1.25) {$$};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
一种方法是
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{50}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[canvas is xy plane at z=0,dashed]
\foreach \X in {0.1,0.3,...,3.9}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (3*\X,0) -- (3*\X,{-2*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (3*\x,{-2*sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thick,solid] (12.2,0) -- (12.8,0);
\end{scope}
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\foreach \X in {0.1,0.3,...,3.9}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (3*\X,0) -- (3*\X,{2*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (3*\x,{2*sin(\x*180)});
\end{scope}
\node at (3*3.5,2.5,0) {$\vec B$};
\node at (3*3.5,0,-2.5) {$\vec E$};
\end{tikzpicture}
\end{document}
您可以像这样将其添加到您的图片中:
\documentclass[tikz,border=3.14mm]{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]{$$}
-- (0,0) -- (pX,0) node[below left]{$$};
\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] (-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];
\end{scope}
\draw[-latex] (4,0,0) -- (5.5,0,0) node[below left]{$$};
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}
\clip (0,-2) rectangle (4,3);
\draw[densely dashed] (0,-2) -- (0,2);
\foreach \X in {0.25,0.75,...,5}
{\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+.25,-2) -- (\X+0.25,2);}
\end{scope}
\end{scope}
%
\begin{scope}[shift={($(-5,0,0)-(0,0,0)$)}]
\begin{scope}[canvas is xy plane at z=0,dashed]
\foreach \X in {0.1,0.3,...,3.9}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{-sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{-sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thick,solid] (12.2,0) -- (12.8,0);
\end{scope}
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\foreach \X in {0.1,0.3,...,3.9}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thick] (1*\X,0) -- (1*\X,{sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{sin(\x*180)});
\end{scope}
\node at (1*3.5,1.75,0) {$\vec B$};
\node at (1*3.5,0,-1.25) {$\vec E$};
\end{scope}
\end{tikzpicture}
\end{document}