我有正弦波,想在上面画一个电波纹,所以我用装饰选项画了一条锯齿线。但是锯齿线的方向与波成直角。我需要一条沿着正弦波方向的锯齿线,方向为 x 轴。这就是我所得到的:
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{snake it/.style={decorate, decoration=snake}}
\newcommand{\drawCoordinateSystem}[2]{
\draw[color=#1, step=.5cm, very thin] (0,-2) grid (7.5,2);
\draw [#2, thick, ->] (0,0) -- (8,0) node[right]{$T$};
\draw [#2, thick, <->](0,2.5) -- (0,-2.5) node[above] {$F$};
}%\end{tikzpicture}%end newCommand
\begin{document}
\vspace*{2cm}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\drawCoordinateSystem{lightgray}{black}
\draw[domain=0:6.5, black, thick] plot (\x,{sin(\x r)}) node[right, above,] {$I$};
\draw[decorate, decoration={zigzag,segment length = .15cm, amplitude = 1.5mm}, domain=0:6.5, thick] plot (\x,{sin(\x r)});
\end{tikzpicture}
\end{center}
\end{document}
有人能帮我解决这个问题吗?
答案1
我猜测“波纹”是另一个频率更高的正弦波,添加到主正弦波中,因此您可以将其绘制为第一个函数之上的另一个函数。
我不得不删除r
(弧度)并调整数字,以避免溢出错误(“数字太大”)。
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\newcommand{\drawCoordinateSystem}[2]{
\draw[color=#1, step=.5cm, very thin] (0,-2) grid (7.5,2);
\draw [#2, thick, ->] (0,0) -- (8,0) node[right]{$T$};
\draw [#2, thick, <->](0,2.5) -- (0,-2.5) node[above] {$F$};
}%\end{tikzpicture}%end newCommand
\begin{document}
\vspace*{2cm}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\drawCoordinateSystem{lightgray}{black}
\draw[domain=0:6.5, black, thick] plot (\x,{sin(\x*60.0)}) node[right, above,] {$I$};
%\draw[decorate, decoration={zigzag,segment length = .15cm, amplitude = 1.5mm}, domain=0:6.5, thick] plot (\x,{sin(\x r)});
\draw[domain=0:6.4, black, thick, samples=200] plot (\x,{sin(\x*60.0)+0.5*sin(\x*960.0});
\end{tikzpicture}
\end{center}
\end{document}
更新
如果您的波纹必须更加“三角”,那么您可以作弊并减少样本数量。如果您选择得当,您可以仅在其峰值处对正弦噪声进行采样,从而获得三角波。例如:
\begin{tikzpicture}[scale=0.8]
\drawCoordinateSystem{lightgray}{black}
\draw[domain=0:6.5, black, thick] plot (\x,{sin(\x*60.0)}) node[right, above,] {$I$};
\draw[domain=0:6.45, black, thick, samples=87] plot (\x,{sin(\x*60.0)+0.5*sin(\x*1200.0});
\end{tikzpicture}
生成: