我写了这段代码:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round]
% First, define nodes
\node[circle, inner sep=0pt, label={[inner sep=0pt]above:{}}] (O) at (0, 0) {};
\node (O01) at (-4.5, 0) {};
\node (O11) at (-4.5, 1.1) {};
\node (O12) at (0, 1.1) {};
\node (O21) at (-4.5, -1.1) {};
\node (O22) at (0, -1.1) {};
% Draw curved path
\draw [inner sep=0pt, line width=2pt, {Stealth[length=4mm]}-{Stealth[length=4mm]}] (O01) -- ($(O01)!2!(O)$);
\draw [inner sep=0pt, line width=2pt, {Stealth[length=4mm]}-{Stealth[length=4mm]}] (O11) -- ($(O11)!2!(O12)$);
\draw [inner sep=0pt, line width=2pt, {Stealth[length=4mm]}-{Stealth[length=4mm]}] (O21) -- ($(O21)!2!(O22)$);
\draw [inner sep=0pt, line width=2pt, -{Stealth[length=4mm]}] (O) -- (30:4.5cm);
\draw [inner sep=0pt, line width=2pt, -{Stealth[length=4mm]}] (O) -- (-50:5cm);
\end{tikzpicture}
\end{document}
我尝试过了
- 在附近画出角度标志和文字,
- 直线上的双箭头,但是我不能。
答案1
- 使用坐标而不是节点来命名图表中的点。节点对于需要文本且具有边框的事物更有用。
- 您可以使用
tips
钥匙仅绘制箭头尖而不绘制路径。 - 找到水平线和“射线”之间的交点:
- 这
angles
图书馆对于绘制角度标记非常有帮助。
我使用了一些颜色来区分图表的不同部分。您可以随意在选项中删除颜色。
代码
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta}
\begin{document}
\begin{tikzpicture}[
thick,
> = { Straight Barb [angle' = 60] },
>>/.tip = { > [sep=+0pt +-2] > },
angle eccentricity = 1.6
]
% define coordinates where horizontal lines start and end
% draw lines and also add extra arrow tips
\foreach[count=\y from -1] \yy in {bottom, center, top}{
\draw[<->] (0, \y) coordinate (line left \yy)
-- +(7, 0) coordinate (line right \yy); % +(…) denotes relative coordinates
\path[->>, tips] (line left \yy) -- +(right:1.25);
}
% define rays and draw them
% find intersection between rays and horizontal lines
\path[->, blue] (2.25, 0) coordinate (ray start)
edge coordinate[at end] (ray down) +(-50:3)
edge coordinate[at end] (ray up) +( 30:4)
(intersection of ray start--ray up and line left top--line right top)
coordinate (rayline top)
(intersection of ray start--ray down and line left bottom--line right bottom)
coordinate (rayline bottom);
% draw angles by defining corner and specifying angle label
% uses angles library
\foreach \Corner/\Label in {
line right top--rayline top--ray up/\mu_0,
line right center--ray start--ray up/\alpha,
ray down--ray start--line right center/\gamma,
ray down--rayline bottom--line right bottom/\omega_0
} \pic[draw, green!50!black, pic text=$\Label$] {angle/.expand once=\Corner};
\end{tikzpicture}
\end{document}
输出
答案2
类似的想法,不同的实现:做出您的选择。
- 先 <-> 行,然后 ->> 行(反之亦然),使用相对坐标
- 如果需要插入文本,请使用角度库和引号
- 到处使用极坐标,比如
\draw[<-] (30:4) ...
- 记住这些坐标以便日后需要时使用
\draw[<-] (30:4) coordinate (A) ...
- 调整或扩展您的风格
[ ... ]
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta,angles,quotes}
%\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[
> = {Stealth},
]
% ~~~ drawing <-> lines ~~~~~~~~~~~~~~~
\draw [<->] (-4.5, 1.1) coordinate (11) -- (4.5, 1.1);
\draw [<->] (-4.5, 0 ) coordinate (01) -- (4.5, 0 );
\draw [<->] (-4.5,-1.1) coordinate (21) -- (4.5,-1.1);
% ~~~ drawing <->> lines ~~~~~~~~~~~~~~~
\draw [->>] (11) -- +(2,0);
\draw [->>] (01) -- +(2,0);
\draw [->>] (21) -- +(2,0);
% ~~~ angles ~~~~~~~~~~~~~~~~~
\draw[<-] (30:4) coordinate (A) -- (0,0) coordinate (zero)
-- (0:.01) coordinate (C)
pic[draw, <->, angle radius=16mm,"$\alpha$"]
{angle = C--zero--A};
\draw[<-] (-40:4) coordinate (A2) -- (0,0) coordinate (zero)
-- (0:.01) coordinate (C)
pic[draw, <->, angle radius=16mm,"$-40^\circ$",red]
{angle = A2--zero--C};
\end{tikzpicture}
\begin{tikzpicture}[line cap=round]
% First, define nodes
\node[circle, inner sep=0pt, label={[inner sep=0pt]above:{}}] (O) at (0, 0) {};
\node (O01) at (-4.5, 0) {01};
\node (O11) at (-4.5, 1.1) {11};
\node (O12) at ( 0, 1.1) {12};
\node (O21) at (-4.5, -1.1) {21};
\node (O22) at ( 0, -1.1) {22};
% Draw curved path
\draw [inner sep=0pt, line width=2pt,
{Stealth[length=4mm]}-{Stealth[length=4mm]}]
(O01) -- ($(O01)!2!(O)$);
\draw [inner sep=0pt, line width=2pt, {Stealth[length=4mm]}-{Stealth[length=4mm]}] (O11) -- ($(O11)!2!(O12)$);
\draw [inner sep=0pt, line width=2pt, {Stealth[length=4mm]}-{Stealth[length=4mm]}] (O21) -- ($(O21)!2!(O22)$);
\draw [inner sep=0pt, line width=2pt, -{Stealth[length=4mm]}] (O) -- (30:4.5cm);
\draw [inner sep=0pt, line width=2pt, -{Stealth[length=4mm]}] (O) -- (-50:5cm);
\end{tikzpicture}
\end{document}