使用 TikZ 绘制弓弦的亥姆霍兹运动

使用 TikZ 绘制弓弦的亥姆霍兹运动

我正在尝试绘制一张图表来说明弓弦的亥姆霍兹运动。这是我目前所得到的:

在此处输入图片描述

但我一直不知道如何绘制适合抛物线的波形。我的目标是像这样:(来源:knutacoustics.com亥姆霍兹运动.pdf

在此处输入图片描述

补充:我还想知道是否可以将其制作成动画,使其看起来像这样?(来源:newt.phys.unsw.edu.au琴弓和琴弦

在此处输入图片描述

代码

\documentclass[tikz,margin=1cm]{standalone}

\begin{document}
\begin{tikzpicture}

\newcommand\stringLen{7cm}
\newcommand\parabolaH{1.5cm}
\newcommand\bridgeNutLen{0.3cm}

\draw (0,0)--(\stringLen,0);
\draw [line width=0.4mm] (0,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Bridge};
\draw [line width=0.4mm] (\stringLen,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Nut};

% Helmholtz Motion
\draw[dashed] (0,0) parabola bend (\stringLen/2,\parabolaH) (\stringLen,0);
\draw[dashed] (0,0) parabola bend (\stringLen/2,-\parabolaH) (\stringLen,0);

% The Bow
\newcommand\bowLen{5cm}
\newcommand\bowPos{1cm}
\newcommand\bowTipLen{0.15cm}
\newcommand\bowTipLenTop{0.05cm}
\newcommand\bowTipWid{0.15cm}
\newcommand\bowFrogLen{0.2cm}
\newcommand\bowFrogLenBase{0.1cm}
\draw (\bowPos,-\bowLen/2)--++(0,\bowLen);
\draw [fill=brown,color=brown,rounded corners=0.1mm] (\bowPos,\bowLen/2)--++(-\bowTipWid,0) --++(0,\bowTipLenTop)  parabola (\bowPos,\bowLen/2 +\bowTipLen)--cycle;
\draw [fill=brown,color=brown,rounded corners=0.1mm] 
(\bowPos,-\bowLen/2)-- (\bowPos,-\bowLen/2 -\bowFrogLenBase) parabola (\bowPos-\bowTipWid,-\bowLen/2 -\bowFrogLen)--++ (0,\bowFrogLen)--cycle;
\draw [color=brown,line width=0.4mm] (\bowPos-\bowTipWid+0.15mm,\bowLen/2) to [bend left=3]  (\bowPos-\bowTipWid+0.15mm,-\bowLen/2);
\draw [line width=0.3mm] (\bowPos-\bowTipWid+0.1mm,-\bowLen/2 -\bowFrogLen+0.5mm)--++(0,-0.8mm);
\node at (\bowPos+0.5cm,-\bowLen/2) {Bow};
\draw [<-,line width=0.3mm] (\bowPos-0.5cm,\bowLen/2)--++(0,-1cm);

\end{tikzpicture}
\end{document}

答案1

这是第一部分。

\documentclass[tikz,margin=1cm]{standalone}
\usetikzlibrary{intersections,calc}

\begin{document}
\begin{tikzpicture}

\newcommand\stringLen{7cm}
\newcommand\parabolaH{1.5cm}
\newcommand\bridgeNutLen{0.3cm}

\draw (0,0)--(\stringLen,0);
\draw [line width=0.4mm] (0,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Bridge};
\draw [line width=0.4mm] (\stringLen,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Nut};

% Helmholtz Motion
\draw[dashed,name path global=parabola] (0,0) parabola bend (\stringLen/2,\parabolaH) (\stringLen,0)
parabola bend (\stringLen/2,-\parabolaH) (0,0);

\foreach \X in {150,160,170}
{\path[name path global=ray] (\stringLen,0) -- ++(\X:\stringLen);
\draw[name intersections={of=parabola and ray}] (\stringLen,0) 
-- (intersection-1)  --(0,0);}
\foreach \X in {190,200,210}
{\path[name path global=ray] (\stringLen,0) -- ++(\X:\stringLen);
\draw[name intersections={of=parabola and ray,total=\t}] (\stringLen,0) 
-- (intersection-2)  --(0,0);}
\path[name path global=ray] (\stringLen,0) -- ++(170:\stringLen);
\draw[name intersections={of=parabola and ray},blue,thick] (\stringLen,0) 
-- (intersection-1)  --(0,0);

% The Bow
\newcommand\bowLen{5cm}
\newcommand\bowPos{1cm}
\newcommand\bowTipLen{0.15cm}
\newcommand\bowTipLenTop{0.05cm}
\newcommand\bowTipWid{0.15cm}
\newcommand\bowFrogLen{0.2cm}
\newcommand\bowFrogLenBase{0.1cm}
\draw (\bowPos,-\bowLen/2)--++(0,\bowLen);
\draw [fill=brown,color=brown,rounded corners=0.1mm] (\bowPos,\bowLen/2)--++(-\bowTipWid,0) --++(0,\bowTipLenTop)  parabola (\bowPos,\bowLen/2 +\bowTipLen)--cycle;
\draw [fill=brown,color=brown,rounded corners=0.1mm] 
(\bowPos,-\bowLen/2)-- (\bowPos,-\bowLen/2 -\bowFrogLenBase) parabola (\bowPos-\bowTipWid,-\bowLen/2 -\bowFrogLen)--++ (0,\bowFrogLen)--cycle;
\draw [color=brown,line width=0.4mm] (\bowPos-\bowTipWid+0.15mm,\bowLen/2) to [bend left=3]  (\bowPos-\bowTipWid+0.15mm,-\bowLen/2);
\draw [line width=0.3mm] (\bowPos-\bowTipWid+0.1mm,-\bowLen/2 -\bowFrogLen+0.5mm)--++(0,-0.8mm);
\node at (\bowPos+0.5cm,-\bowLen/2) {Bow};
\draw [<-,line width=0.3mm] (\bowPos-0.5cm,\bowLen/2)--++(0,-1cm);

\end{tikzpicture}
\end{document}

在此处输入图片描述

动画如下。

\documentclass[tikz,margin=1cm]{standalone}
\usetikzlibrary{intersections}

\begin{document}
\foreach \Y in {1,2,3,4,5}
{\foreach \X in {140,145,...,220}
{\begin{tikzpicture}
\pgfmathsetmacro{\Z}{\Y+(\X-140)/80}
%\pgfmathsetmacro{\Z}{2}
\newcommand\stringLen{7cm}
\newcommand\parabolaH{1.5cm}
\newcommand\bridgeNutLen{0.3cm}

\path[use as bounding box] (0,-0.6*\stringLen) rectangle (1.1*\stringLen,0.6*\stringLen);

\draw (0,0)--(\stringLen,0);
\draw [line width=0.4mm] (0,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Bridge};
\draw [line width=0.4mm] (\stringLen,-\bridgeNutLen)--++(0,2*\bridgeNutLen) node [yshift=-1cm] {Nut};

% Helmholtz Motion
% \draw[dashed,name path global=upper parabola] (0,0) parabola bend (\stringLen/2,\parabolaH) (\stringLen,0);
% \draw[dashed,name path global=lower parabola] (0,0) parabola bend (\stringLen/2,-\parabolaH) (\stringLen,0);

\draw[dashed,name path global=upper parabola] 
plot[domain=0:1] ({\x*\stringLen},{\parabolaH*(1-4*(\x-1/2)*(\x-1/2))});
\draw[dashed,name path global=lower parabola] 
plot[domain=0:1] ({\x*\stringLen},{-\parabolaH*(1-4*(\x-1/2)*(\x-1/2))})
;

\pgfmathtruncatemacro{\inum}{ifthenelse(\X<180,1,2)}
\path[name path global=ray] (\stringLen,0) -- ++(\X:\stringLen);
\ifnum\inum=1
\draw[name intersections={of=upper parabola and ray},blue,thick] (\stringLen,0) 
-- (intersection-1)  --(0,0);
\path[name path global=extra]  (intersection-1)  --(0,0);
\else
\draw[name intersections={of=lower parabola and ray},blue,thick] (\stringLen,0) 
-- (intersection-1)  --(0,0);
\path[name path global=extra]  (intersection-1)  --(0,0);
\fi
% The Bow
\begin{scope}[yshift={0.3*(\Z-2)*1cm}]
\newcommand\bowLen{5cm}
\newcommand\bowPos{1cm}
\newcommand\bowTipLen{0.15cm}
\newcommand\bowTipLenTop{0.05cm}
\newcommand\bowTipWid{0.15cm}
\newcommand\bowFrogLen{0.2cm}
\newcommand\bowFrogLenBase{0.1cm}
\draw[name path=string] (\bowPos,-\bowLen/2)--++(0,\bowLen);
\draw [fill=brown,color=brown,rounded corners=0.1mm] (\bowPos,\bowLen/2)--++(-\bowTipWid,0) --++(0,\bowTipLenTop)  parabola (\bowPos,\bowLen/2 +\bowTipLen)--cycle;
\draw [fill=brown,color=brown,rounded corners=0.1mm] 
(\bowPos,-\bowLen/2)-- (\bowPos,-\bowLen/2 -\bowFrogLenBase) parabola (\bowPos-\bowTipWid,-\bowLen/2 -\bowFrogLen)--++ (0,\bowFrogLen)--cycle;
\draw [color=brown,line width=0.4mm] (\bowPos-\bowTipWid+0.15mm,\bowLen/2) to [bend left=3]  (\bowPos-\bowTipWid+0.15mm,-\bowLen/2);
\draw [line width=0.3mm] (\bowPos-\bowTipWid+0.1mm,-\bowLen/2 -\bowFrogLen+0.5mm)--++(0,-0.8mm);
\node at (\bowPos+0.5cm,-\bowLen/2) {Bow};
\draw [<-,line width=0.3mm] (\bowPos-0.5cm,\bowLen/2)--++(0,-1cm);
\path[name intersections={of=string and extra,total=\t}]
{\pgfextra{\xdef\inum{\t}}};
\ifnum\inum=1
\draw[red] (intersection-1) circle (1.5pt);
\fi
\end{scope}
\end{tikzpicture}
}}
\end{document}

在此处输入图片描述

编辑交叉点有问题,所以我不得不用其他方式重新绘制抛物线。我还添加了圆,抱歉发垃圾信息!

相关内容