I have the code which outputs a couple of sinusoidal functions
\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 {2.1,2.3,...,4}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thin] (1*\X,0) -- (1*\X,{-2*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=2:4,samples=41] (1*\x,{-2*sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thin,solid] (12.2,0) -- (12.8,0);
\end{scope}
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\foreach \X in {2.1,2.3,...,4}
{\begin{scope}
\pgflowlevelsynccm
\draw[-latex,thin] (1*\X,0) -- (1*\X,{2*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=2:4,samples=41] (1*\x,{2*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,thin] (1*\X,0) -- (1*\X,{-3*exp(-\X)*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{-3*exp(-\x)*sin(\x*180)});
\begin{scope}
\pgflowlevelsynccm
\draw[-latex,ultra thin,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,thin] (1*\X,0) -- (1*\X,{3*exp(-\X)*sin(\X*180)});
\end{scope}
}
\draw plot[smooth,domain=0:4,samples=41] (1*\x,{3*exp(-\x)*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}
where I want the wave on the right of the image, to have a random amplitude. So it looks random, and decays. How can I achieve this in tikz?
pgf
has a couple of random number functions,rnd
andrand
.