使用该选项时如何反转箭头的方向tkz arrow
?我在\tkzDrawArc
命令中使用该选项,它似乎总是想沿正方向绘制圆弧。
\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\draw (-2,-2) rectangle (5,2);
\tkzDefPoints{0/0/O,3/0/U}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzLabelPoints(A,B)
\tkzDrawArc[tkz arrow](O,A)(B)
\tkzDrawPoints(A,B,O)
\begin{scope}[shift=(U)]
\tkzDefPoints{0/0/O}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzDrawArc[tkz arrow](O,B)(A)
\tkzLabelPoints(A,B)
\tkzDrawPoints(A,B,O)
\end{scope}
\end{tikzpicture}
\end{document}
答案1
如果是选项tkz arrow
,箭头的类型、大小和方向都是默认的,所以tkz arrow
相当于tkz arrow={Latex[scale=1]}
。如果要反转箭头的方向, 的值scale
必须为负数,例如tkz arrow={Latex[scale=-1]}
。
\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\draw (-2,-2) rectangle (5,2);
\tkzDefPoints{0/0/O,3/0/U}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzLabelPoints(A,B)
\tkzDrawArc[tkz arrow={Latex[scale=-1]}](O,A)(B)
\tkzDrawPoints(A,B,O)
\begin{scope}[shift=(U)]
\tkzDefPoints{0/0/O}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzDrawArc[tkz arrow={Latex[scale=-1]}](O,B)(A)
\tkzLabelPoints(A,B)
\tkzDrawPoints(A,B,O)
\end{scope}
\end{tikzpicture}
\end{document}
答案2
好的解决方案实际上来自一丝不苟。你的问题很有趣,因为它让我想到了修改宏的代码/tkzDrawArc
。我需要一些测试来检查是否没有不良副作用。
现在可以使用该选项reverse
来绘制弧线。
\documentclass{standalone}
\usepackage{tkz-euclide}
\makeatletter
\newif\iftkz@reverse
\gdef\tkz@numa{0}
\pgfkeys{/tkzdrawarc/.cd,
type/.is choice,
type/towards/.code = \def\tkz@numa{0},
type/rotate/.code = \def\tkz@numa{1},
type/angles/.code = \def\tkz@numa{2},
type/R/.code = \def\tkz@numa{3},
type/R with nodes/.code = \def\tkz@numa{4},
towards/.style = {type=towards},
rotate/.style = {type=rotate},
R/.style = {type=R},
angles/.style = {type=angles},
R with nodes/.style = {type=R with nodes},
diameter/.code = {},
arc/.code = {},
size/.code = {},
mark/.code = {},
mkpos/.code = {},
mksize/.code = {},
mkcolor/.code = {},
type/.default = towards,
delta/.store in = \tkz@delta,
delta = 0,
reverse/.is if = tkz@reverse,
reverse/.default = true,
reverse = false,
/tkzdrawarc/.search also = {/tikz}
}
\def\tkzDrawArcRAngles{\pgfutil@ifnextchar[{\tkz@DrawArcRAngles}{%
\tkz@DrawArcRAngles[]}}
\def\tkz@DrawArcRAngles[#1](#2,#3)(#4,#5){%
\begingroup
\tkzNormalizeAngle(#4,#5)
\pgfmathsubtract{\tkz@FirstAngle}{\tkz@delta}
\edef\tkz@FirstAngle{\pgfmathresult}%
\pgfmathadd{\tkz@SecondAngle}{\tkz@delta}
\edef\tkz@SecondAngle{\pgfmathresult}
\iftkz@reverse
\let\tkztemp\tkz@FirstAngle
\let\tkz@FirstAngle\tkz@SecondAngle
\let\tkz@SecondAngle\tkztemp
\fi
\draw[shift = {(#2)},arc style,/tkzdrawarc/.cd,#1]%
(\tkz@FirstAngle:#3) arc (\tkz@FirstAngle:\tkz@SecondAngle:#3);
\endgroup
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw (-2,-2) rectangle (5,2);
\tkzDefPoints{0/0/O,3/0/U}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzLabelPoints(A,B)
\tkzDrawArc[reverse,tkz arrow={Stealth}](O,A)(B)
\tkzDrawPoints(A,B,O)
\begin{scope}[shift=(U)]
\tkzDefPoints{0/0/O}
\tkzDefPoint(10:1){A}
\tkzDefPoint(90:1){B}
\tkzDrawArc[tkz arrow={Stealth}](O,A)(B)
\tkzLabelPoints(A,B)
\tkzDrawPoints(A,B,O)
\end{scope}
\end{tikzpicture}
\end{document}