2

How do I reverse the direction of the arrow head when using the tkz arrow option? I am using the option in the \tkzDrawArc command which always seems to want to draw the arc in the positive direction.

\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}

enter image description here

3
  • 3
    Try this: \tkzDrawArc[tkz arrow={Latex[scale=-1]}] Apr 18, 2022 at 19:10
  • That is what was needed. Apr 18, 2022 at 19:54
  • 1
    @hair-splitter Can you please place your comment in an answer because it's a solution. Apr 19, 2022 at 9:42

2 Answers 2

3

In case option tkz arrow, the type, size, and direction of the arrow are the default, so tkz arrow is equivalent to tkz arrow={Latex[scale=1]}. If you want to reverse the direction of the arrow, the value of scale must be negative, for example 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}

enter image description here

2

The good solution actually comes from hair-splitter. Your question is interesting because it allowed me to think about a modification of the code of the macro /tkzDrawArc. I need some tests to check if there are no unwanted side effects.

Now it's possible to use the option reverse to draw the arc.

\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}

enter image description here

5
  • Will you put this idea in the next version of tkz-euclide? Apr 19, 2022 at 10:48
  • 1
    @hair-splitter yes it's already done but I will test with my documentation before validating Apr 19, 2022 at 10:52
  • I'm so glad, thank you! Apr 19, 2022 at 10:53
  • This will be useful because it replicates the behavior of drawing a line segment. Apr 20, 2022 at 2:18
  • @MátéWierdl You should accept the Hair-splitter solution it is the most natural and it can be applied outside tkz-euclide Apr 20, 2022 at 4:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .