我怎样才能移动角度注释文本以避免与圆弧重叠?
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
\draw let \p1=($(#1)-(#2)$),
\p2=($(#3)-(#2)$),
\n1={atan2(\y1,\x1)},
\n2={atan2(\y2,\x2)}
in
(#2)++(\n1:5pt) arc (\n1:\n2:5pt) node[midway,sloped] {$#4$} ;
}
\begin{document}
\begin{tikzpicture}[scale=2]
\pgfmathsetmacro\a{60}
\coordinate (O) at (0,0);
\coordinate (A) at ({cos(\a)},{sin(\a)});
\coordinate (B) at (-1,0);
\coordinate (C) at (1,0);
\draw (O) circle (1);
\draw (A) -- (B) -- (C) -- cycle
(A) -- (O)
;
\ann{O}{B}{A}{\theta};
\ann{O}{A}{B}{\theta};
\ann{O}{A}{C}{\beta};
\ann{O}{C}{A}{\beta};
\foreach \x in {A,B,C,O} {
\node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
}
\end{tikzpicture}
\end{document}
答案1
为了便于阅读,我不会倾斜角度。相反,
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
\draw let \p1=($(#1)-(#2)$),
\p2=($(#3)-(#2)$),
\n1={atan2(\y1,\x1)},
\n2={atan2(\y2,\x2)}
in
(#2)++(\n1:5pt) arc (\n1:\n2:5pt) (#2)++({(\n1+\n2)/2}:9pt) node {$#4$} ;
}
\begin{document}
\begin{tikzpicture}[scale=2]
\pgfmathsetmacro\a{60}
\coordinate (O) at (0,0);
\coordinate (A) at ({cos(\a)},{sin(\a)});
\coordinate (B) at (-1,0);
\coordinate (C) at (1,0);
\draw (O) circle (1);
\draw (A) -- (B) -- (C) -- cycle
(A) -- (O)
;
\ann{O}{B}{A}{\theta};
\ann{O}{A}{B}{\theta};
\ann{O}{A}{C}{\beta};
\ann{O}{C}{A}{\beta};
\foreach \x in {A,B,C,O} {
\node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
}
\end{tikzpicture}
\end{document}
(从您之前的问题中我认为您不想使用该angles
库,它也允许您注释角度。)
如果你想让它们倾斜,你也可以这样做。(我不知道你是否想添加 90 度的旋转角度,这也是可以做到的。)
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,angles,quotes,through}
\newcommand{\ann}[4]{
\draw let \p1=($(#1)-(#2)$),
\p2=($(#3)-(#2)$),
\n1={atan2(\y1,\x1)},
\n2={atan2(\y2,\x2)}
in
(#2)++(\n1:5pt) arc (\n1:\n2:5pt) (#2)++({(\n1+\n2)/2}:9pt)
node[rotate={(\n1+\n2)/2+ifthenelse(cos((\n1+\n2)/2)<0,180,0)}] {$#4$} ;
}
\begin{document}
\begin{tikzpicture}[scale=2]
\pgfmathsetmacro\a{60}
\coordinate (O) at (0,0);
\coordinate (A) at ({cos(\a)},{sin(\a)});
\coordinate (B) at (-1,0);
\coordinate (C) at (1,0);
\draw (O) circle (1);
\draw (A) -- (B) -- (C) -- cycle
(A) -- (O)
;
\ann{O}{B}{A}{\theta};
\ann{O}{A}{B}{\theta};
\ann{O}{A}{C}{\beta};
\ann{O}{C}{A}{\beta};
\foreach \x in {A,B,C,O} {
\node[circle,inner sep=0,minimum size=1pt,label=\x] at (\x) {};
}
\end{tikzpicture}
\end{document}
答案2
您可以使用包中的选项 tkzMarkAngle
来注释角度。tkzLabelAngle
tkz-euclide
\documentclass[border=3mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=2]
\tkzDefPoint(0,0){O}
\tkzDefPoint(60:1){A}
\tkzDefPoint(-1,0){B}
\tkzDefPoint(1,0){C}
\draw (O) circle (1);
\draw (A) -- (B) -- (C) -- cycle
(A) -- (O)
;
\tkzLabelPoints[above](A,B,C,O)
\tkzMarkAngle[size=2ex](O,B,A)
\tkzMarkAngle[size=2ex](B,A,O)
\tkzMarkAngle[size=1ex](O,A,C)
\tkzMarkAngle[size=2ex](A,C,O)
\tkzLabelAngle[pos=0.4](O,B,A){$\theta$}
\tkzLabelAngle[pos=0.4](B,A,O){$\theta$}
\tkzLabelAngle[pos=0.25](O,A,C){$\theta$}
\tkzLabelAngle[pos=0.4](A,C,O){$\theta$}
\end{tikzpicture}
\end{document}