我试图使绿色的左箭头指向左边并且尾部位于最左边的蓝色字符串上,指向右边的右绿色箭头已经是正确的。
问题是,我真的无法放置左边的绿色箭头或正确指向它。
这是我的代码:
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Waves
\usepackage{tikz}
\usetikzlibrary{arrows.meta} % for arrow size
\tikzset{>=latex} % for LaTeX arrow head
\colorlet{xcol}{blue!70!black}
\colorlet{vcol}{green!60!black}
\colorlet{myred}{red!70!black}
\tikzstyle{vvec}=[->,vcol,very thick,line cap=round]
\tikzstyle{myarr}=[-{Latex[length=3,width=2]},myred]
\def\tick#1#2{\draw[thick] (#1) ++ (#2:0.1) --++ (#2-180:0.2)}
\def\xpeak#1{{(0.21+#1)*\xmax}}
\def\wave#1{
\coordinate (F) at (\xpeak{#1},\ypeak);
\draw[very thick,xcol]
(-0.08*\xmax,0) -- ({(0.06+#1)*\xmax},0) to[out=0,in=180,looseness=0.5] (F)
to[out=0,in=180,looseness=0.6]++ (0.25*\xmax,-\ypeak) -- (0.94*\xmax,0);
}
\begin{document}
\section{Vibrating string}
% WAVE t = 0
\def\xmax{6.8}
\def\ymax{1.3}
\def\A{0.82*\ymax}
\def\v{0.10*\xmax}
\def\lamb{0.4*\xmax} % wavelength (radians)
\def\om{360/(\lamb)} % omega (degrees)
\def\xa{0.38*\lamb} % point x_1
\def\xb{1.38*\lamb} % point x_2
\def\ya{\A*sin(\om*\xa)} % point y_1 = y_2
\begin{tikzpicture}
\draw[->,thick] (-0.2*\ymax,0) -- (1.05*\xmax,0) node[right=4,below left=1] {$x$};
\draw[->,thick] (0,-\ymax) -- (0,1.08*\ymax) node[left=1] {$y$};
\draw[xcol,very thick,samples=100,smooth,variable=\x,domain=0:\xmax]
plot(\x,{\A*sin(\om*\x)});
\draw[dashed]
(0,\A) --++ (1.35*\lamb,0)
(0,-\A) --++ (1.87*\lamb,0);
\draw[<->] (\xa, 1.24*\A) -- (\xb, 1.24*\A) node[midway,fill=white,inner sep=1] {$\lambda$};
\tick{0,\A}{0} node[scale=0.9,left=-1] {$A$};
\tick{0,-\A}{0} node[scale=0.9,left=-1] {$-A$};
\draw[vvec] (1.5*\lamb,0)++(6:2.5*\A) --++ (\v,0) node[above=1,right=-1] {$T$};
\draw[vvec] (1.5*\lamb,0)++(-8:-2.5*\A) --++ (\v,0) node[above=1,left=1] {$T$};
\end{tikzpicture}
\end{document}
答案1
试试这个代码:
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=3pt,scale=2]
\fill[gray!10] (-0.5,-1.5) rectangle (6,1.8); % prepara il colore di fondo
\draw [->,style=thick] (-.2,0) -- (5.2,0) node[pos=1,right] {distance};
\draw [->,style=thick] (0,-1.30) -- (0,1.3) node[pos=1,above] {displacement};
\draw[thick] (-0.05,1) to (0.05,1) node[black,left] at (-0.05,1) {$+A$};
\draw[thick] (-0.05,-1) to (0.05,-1) node[black,left] at (-0.05,-1) {$-A$};
\draw [cyan,domain=0:5, samples=100] plot (\x, {sin(180*\x)});
\draw[<-,line width=1pt] (.5,1.3)--(1.1,1.3);
\draw[->,line width=1pt] (1.9,1.3)--(2.5,1.3);
\draw[dotted,line width=.5pt] (.5,0)--(.5,1.3);
\draw[dotted,line width=.5pt] (2.5,0)--(2.5,1.3);
\draw[<-,line width=1pt] (1.5,-1.3)--(2.1,-1.3);
\draw[->,line width=1pt] (2.9,-1.3)--(3.5,-1.3);
\draw[dotted,line width=.5pt] (1.5,0)--(1.5,-1.3);
\draw[dotted,line width=.5pt] (3.5,0)--(3.5,-1.3);
\draw [red] node[fill=white] at (1.5,1.3) {wave length, $\lambda$};
\draw [red] node[fill=white] at (2.5,-1.3) {wave length, $\lambda$};
\draw[<->,dotted,line width=.5pt] (.5,0)--(.5,1);
\draw[green,line width=2,-latex] (.1,{sin(18)})--(-.3,{sin(18)}) node[left] () {$T$};
\draw[green,line width=2,-latex] (4.9,{sin(18)})--(5.3,{sin(18)}) node[right] () {$T$};
\end{tikzpicture}
\end{document}
输出:
答案2
对于指向左侧的绿色箭头
要更改的语法如下行
\draw[vvec] (1.5*\lamb,0)++(-8:-2.5*\A) --++ (\v,0) node[above=1,left=1] {$T$};
需要修改为
\draw[vvec] (1.5*\lamb,0)++(-5:-3.7*\A) --++ (-\v,0) node[above=1,left=1] {$T$};
用于将 lambda 与 sin 曲线的峰值对齐
改变了现有的点\xa
和点的定义\xb
\def\xa{0.38*\lamb} % point x_1
\def\xb{1.38*\lamb} % point x_2
到以下
\def\xa{0.24*\lamb} % point x_1
\def\xb{1.24*\lamb} % point x_2
平均能量损失
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Waves
\usepackage{tikz}
\usetikzlibrary{arrows.meta} % for arrow size
\tikzset{>=latex} % for LaTeX arrow head
\colorlet{xcol}{blue!70!black}
\colorlet{vcol}{green!60!black}
\colorlet{myred}{red!70!black}
\tikzstyle{vvec}=[->,vcol,very thick,line cap=round]
\tikzstyle{myarr}=[-{Latex[length=3,width=2]},myred]
\def\tick#1#2{\draw[thick] (#1) ++ (#2:0.1) --++ (#2-180:0.2)}
\def\xpeak#1{{(0.21+#1)*\xmax}}
\def\wave#1{
\coordinate (F) at (\xpeak{#1},\ypeak);
\draw[very thick,xcol]
(-0.08*\xmax,0) -- ({(0.06+#1)*\xmax},0) to[out=0,in=180,looseness=0.5] (F)
to[out=0,in=180,looseness=0.6]++ (0.25*\xmax,-\ypeak) -- (0.94*\xmax,0);
}
\begin{document}
\section{Vibrating string}
% WAVE t = 0
\def\xmax{6.8}
\def\ymax{1.3}
\def\A{0.82*\ymax}
\def\v{0.10*\xmax}
\def\lamb{0.4*\xmax} % wavelength (radians)
\def\om{360/(\lamb)} % omega (degrees)
\def\xa{0.24*\lamb} % point x_1
\def\xb{1.24*\lamb} % point x_2
\def\ya{\A*sin(\om*\xa)} % point y_1 = y_2
\begin{tikzpicture}
\draw[->,thick] (-0.2*\ymax,0) -- (1.05*\xmax,0) node[right=4,below left=1] {$x$};
\draw[->,thick] (0,-\ymax) -- (0,1.08*\ymax) node[left=1] {$y$};
\draw[xcol,very thick,samples=100,smooth,variable=\x,domain=0:\xmax]
plot(\x,{\A*sin(\om*\x)});
\draw[dashed]
(0,\A) --++ (1.35*\lamb,0)
(0,-\A) --++ (1.87*\lamb,0);
\draw[<->] (\xa, 1.24*\A) -- (\xb, 1.24*\A) node[midway,fill=white,inner sep=1] {$\lambda$};
\tick{0,\A}{0} node[scale=0.9,left=-1] {$A$};
\tick{0,-\A}{0} node[scale=0.9,left=-1] {$-A$};
\draw[vvec] (1.5*\lamb,0)++(6:2.5*\A) --++ (\v,0) node[above=1,right=-1] {$T$};
\draw[vvec] (1.5*\lamb,0)++(-5:-3.7*\A) --++ (-\v,0) node[above=1,left=1] {$T$};
\end{tikzpicture}
\end{document}
编辑
虽然lambda
已被赋予了白色背景,但由于 的默认背景已经是白色,因此不可见paper/article
- 因此需要为 提供grey
背景sin wave
- 通过包括以下内容
\fill[gray!10] (-1.5,-1.5) rectangle (8,1.8);
平均能量损失
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Waves
\usepackage{tikz}
\usetikzlibrary{arrows.meta} % for arrow size
\tikzset{>=latex} % for LaTeX arrow head
\colorlet{xcol}{blue!70!black}
\colorlet{vcol}{green!60!black}
\colorlet{myred}{red!70!black}
\tikzstyle{vvec}=[->,vcol,very thick,line cap=round]
\tikzstyle{myarr}=[-{Latex[length=3,width=2]},myred]
\def\tick#1#2{\draw[thick] (#1) ++ (#2:0.1) --++ (#2-180:0.2)}
\def\xpeak#1{{(0.21+#1)*\xmax}}
\def\wave#1{
\coordinate (F) at (\xpeak{#1},\ypeak);
\draw[very thick,xcol]
(-0.08*\xmax,0) -- ({(0.06+#1)*\xmax},0) to[out=0,in=180,looseness=0.5] (F)
to[out=0,in=180,looseness=0.6]++ (0.25*\xmax,-\ypeak) -- (0.94*\xmax,0);
}
\begin{document}
\section{Vibrating string}
% WAVE t = 0
\def\xmax{6.8}
\def\ymax{1.3}
\def\A{0.82*\ymax}
\def\v{0.10*\xmax}
\def\lamb{0.4*\xmax} % wavelength (radians)
\def\om{360/(\lamb)} % omega (degrees)
\def\xa{0.24*\lamb} % point x_1
\def\xb{1.24*\lamb} % point x_2
\def\ya{\A*sin(\om*\xa)} % point y_1 = y_2
\begin{tikzpicture}
\fill[gray!10] (-1.5,-1.5) rectangle (8,1.8);
\draw[->,thick] (-0.2*\ymax,0) -- (1.05*\xmax,0) node[right=4,below left=1] {$x$};
\draw[->,thick] (0,-\ymax) -- (0,1.08*\ymax) node[left=1] {$y$};
\draw[xcol,very thick,samples=100,smooth,variable=\x,domain=0:\xmax]
plot(\x,{\A*sin(\om*\x)});
\draw[dashed]
(0,\A) --++ (1.35*\lamb,0)
(0,-\A) --++ (1.87*\lamb,0);
\draw[<->] (\xa, 1.24*\A) -- (\xb, 1.24*\A) node[midway,fill=white,inner sep=1] {$\lambda$};
\tick{0,\A}{0} node[scale=0.9,left=-1] {$A$};
\tick{0,-\A}{0} node[scale=0.9,left=-1] {$-A$};
\draw[vvec] (1.5*\lamb,0)++(6:2.5*\A) --++ (\v,0) node[above=1,right=-1] {$T$};
\draw[vvec] (1.5*\lamb,0)++(-5:-3.7*\A) --++ (-\v,0) node[above=1,left=1] {$T$};
\end{tikzpicture}
\end{document}
和输出