2

I want to draw a trigonometric circle to represent a negative angle and defined a negative polar coordinate like \tkzDefPoint(-60:1){Q} to draw an arc, arc label and a sector on it. Given that the angle value is negative(-60), I expected the commands \tkzDrawArc and \tkzDrawSector to be drawn clockwise, but they were drawn in its default direction, counterclockwise. Even the position of the arc label drawn by \tkzLabelArc is far from the arc and appears to be positioned counterclockwise. How can I change the direction of drawing the arc, arc label and sector from counterclockwise to clockwise?? I tried using the reverse option but it didn't work.

\documentclass{standalone}
\usepackage{tikz,tkz-euclide}
\begin{document}

\begin{tikzpicture}
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(1,0){A}
  \tkzDefPoint(-60:1){Q}

  \tkzDrawCircle[draw=black](O,A)

  \tkzDrawSector[R with nodes,fill=blue,line width=0.2pt](O,1)(A,Q)

  \tkzDrawSegment[thin](O,Q)

  \tkzDrawPoint[fill=black](Q)
  \tkzDrawPoint[fill=black](A)
  \draw[-{Stealth}] (-1.5,0) -- (1.5,0) node[right,xshift=-3pt] {\tiny$x$};
  \draw[-{Stealth}] (0,-1.5) -- (0,1.5) node[above,yshift=-3pt] {\tiny$y$};

  \tkzLabelPoint[below](Q){\tiny$Q$}
  \tkzLabelPoint[below left](O){\tiny$O$}
  \tkzLabelPoint[above right](A){\tiny$A$}

  \tkzDrawArc[-{Stealth}, line width=1pt](O,A)(Q)
\tkzLabelArc[below right](O,A,Q){$-$}
\end{tikzpicture}
\end{document}

The image below shows what I want: counterclockwise arc

10
  • 5
    Unless your code will compile when copied there will be few to no answers …
    – MS-SPO
    Commented 12 hours ago
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented 12 hours ago
  • 2
    @MS-SPO I edited the code. Thank you for your opinion. Commented 11 hours ago
  • 2
    @Jasper I edited the code. Thank you for your opinion. Commented 11 hours ago
  • 1
    Your question (currently) is "How can I change the direction of drawing the arc and sector from counterclockwise to clockwise??" and shows two images both of which have all labels in the same places, one marked as good and one bad. Your criticisms of the two answers you have - both of which draw the arc as in your "good" picture - are about the "label position" which you don't ask about at all. Maybe you need to revise your question.
    – DrM
    Commented 10 hours ago

2 Answers 2

4

Note added, following discussion in comments, etc:

This library has various commands that draw or use arcs, here you use the DrawSector, DrawArc, LabelArc. Each of these commands takes a sequence of arguments {o, S, T}: an origin, a Start S, and an end T.

  • The library considers the arc as going "from" S "to" T, anticlockwise
  • It seems that you would like to consider the arc as:
    • counting "up" (anticlockwise) from S to T if T > S
    • counting "down" (backwards, clockwise) if T < S

I can't see any obvious pitfalls in implementing a library with your preferred logic, but it's not how this library works, and no amount of rephrasing your question will change that.

You could perhaps write wrapper functions that test S > T and pass the arguments on to the library commands in the appropriate order, e.g. myDrawArc, but you would need some care in reversing optional arguments -- in this example, we have an arrow that needs to be reversed; what if you had, say, some fancy shading on the sector fill? (i.e. I think it would be potentially complicated and messy, rather than the "cleaner" code you are looking for, but you can consider whether it would work in your use case.)

my answer below aims to demonstrate how the library's logic works, by swapping the order of S and T (your Q and A), and how (or one possible way) to get a "clockwise" arrow on an "anticlockwise" arc. I showed the switch for the DrawArc and LabelArc but I didn't do it for DrawSector (based on your original picture). But of course you can do that as well, as shown in Sebastiano's answer.

===== earlier answer ===

Think of the arc syntax as going "from" a to b, anticlockwise. So draw the arc "from" Q to A. Then reverse the arrow. Edit: seems you also want "from Q to A" for the label.

\tkzDrawArc[-{Stealth}, line width=1pt,reverse](O,Q)(A)
\tkzLabelArc[below right](O,Q,A){$-$}

enter image description here

\documentclass{standalone}
\usepackage{tikz,tkz-euclide}
\begin{document}

\begin{tikzpicture}
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(1,0){A}
  \tkzDefPoint(-60:1){Q}

  \tkzDrawCircle[draw=black](O,A)

  \tkzDrawSector[R with nodes,fill=blue,line width=0.2pt](O,1)(A,Q)

  \tkzDrawSegment[thin](O,Q)

  \tkzDrawPoint[fill=black](Q)
  \tkzDrawPoint[fill=black](A)
  \draw[-{Stealth}] (-1.5,0) -- (1.5,0) node[right,xshift=-3pt] {\tiny$x$};
  \draw[-{Stealth}] (0,-1.5) -- (0,1.5) node[above,yshift=-3pt] {\tiny$y$};

  \tkzLabelPoint[below](Q){\tiny$Q$}
  \tkzLabelPoint[below left](O){\tiny$O$}
  \tkzLabelPoint[above right](A){\tiny$A$}

  \tkzDrawArc[-{Stealth}, line width=1pt,reverse](O,Q)(A)
\tkzLabelArc[below right](O,Q,A){$-$}
\end{tikzpicture}
\end{document}
7
  • I was on page 116 of the manual :-). I not saw the reverse option. 26.1.9. Option reverse: inversion of the arrow: pag. 139.
    – Sebastiano
    Commented 11 hours ago
  • I drew the arc clockwise just like you did before opening this topic, but the problem is that the label position is too far from the arc itself. You might say that you can adjust its position manually, but this method does not comply with the principles of clean coding and best project rules at all. I think there could be better ways... Commented 11 hours ago
  • 1
    Well, you probably also want to change the label line to \tkzLabelArc[below right](O,Q,A){$-$} if you want to label the arc going from Q to A. But you don't ask about the label in your question.
    – DrM
    Commented 11 hours ago
  • 1
    @Sebastiano I'm not sure what the OP wanted tbh but it seems logical to change the "LabelArc" to match change to the "DrawArc", I think
    – DrM
    Commented 10 hours ago
  • 1
    Of course the same change can also be made to the drawsector as @Sebastiano has done but I think fundamentally the OP wants the syntax to behave differently than this library offers.
    – DrM
    Commented 10 hours ago
3

Some thing like this?

enter image description here

    \documentclass{article}
    \usepackage{tikz}
    \usepackage{tkz-euclide}
    \usetikzlibrary{arrows.meta}
    \begin{document}
    
    \begin{tikzpicture}
    \tkzDefPoint(0,0){O}
    \tkzDefPoint(1,0){A}         
    \tkzDefPoint(-60:1){Q}
    \tkzDrawCircle[draw=black](O,A)
    \tkzDrawSector[R with nodes, fill=blue!20, line width=0.2pt](O,1)(Q,A)
    \tkzDrawSegment[thin](O,Q)
    
    \tkzDrawPoint[fill=black](Q)
    \tkzDrawPoint[fill=black](A)
    \draw[-{Stealth}] (-1.5,0) -- (1.5,0) node[right,xshift=-3pt] {\tiny$x$};
    \draw[-{Stealth}] (0,-1.5) -- (0,1.5) node[above,yshift=-3pt] {\tiny$y$};
    
    \tkzLabelPoint[below](Q){\tiny$Q$}
    \tkzLabelPoint[below left](O){\tiny$O$}
    \tkzLabelPoint[above right](A){\tiny$A$}
    
    \tkzDrawArc[{Stealth}-, line width=1pt](O,Q)(A)
    \end{tikzpicture}
    
    \end{document}

Addendum: using \tkzLabelArc[pos=0.5, shift={(-.1,3pt)}](O,A,Q){$-$}

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}
  \tkzDefPoint(0,0){O}
  \tkzDefPoint(1,0){A}         
  \tkzDefPoint(-60:1){Q}
  
  \tkzDrawCircle[draw=black](O,A)
  
  % (clockwise sector)
  \tkzDrawSector[R with nodes, fill=blue!20, line width=0.2pt](O,1)(Q,A)
  
  % A -> Q (complement)
  \tkzDrawSector[R with nodes, fill=orange!20, line width=0.2pt](O,1)(A,Q)
  
  \tkzDrawSegment[thin](O,Q)
  
  \tkzDrawPoint[fill=black](Q)
  \tkzDrawPoint[fill=black](A)
  
  \draw[-{Stealth}] (-1.5,0) -- (1.5,0) node[right,xshift=-3pt] {\tiny $x$};
  \draw[-{Stealth}] (0,-1.5) -- (0,1.5) node[above,yshift=-3pt] {\tiny $y$};
  
  \tkzLabelPoint[below](Q){\tiny $Q$}
  \tkzLabelPoint[below left](O){\tiny $O$}
  \tkzLabelPoint[above right](A){\tiny $A$}
  
 \tkzLabelArc[pos=0.5, shift={(-.1,3pt)}](O,A,Q){$-$}
\tkzDrawArc[{Stealth}-, line width=1pt](O,Q)(A)
\end{tikzpicture}

\end{document}
5
  • 1
    You deleted the label of arc and as i mentained for @DrM, the label position is too far from the arc itself. I don't want to adjust its position manually, beacuse this method does not comply with the principles of clean code. I am following for a better method. Commented 11 hours ago
  • @JafarManteghi Please can you see my edit? Thank you.
    – Sebastiano
    Commented 11 hours ago
  • 1
    So far I knew how to draw, maybe the arc itself is drawn correctly, but look at the position of the arc label. It is still in the counterclockwise direction, which means according to the logic of the tikz, our arc is still counterclockwise. Also, manual positioning is not suitable at all because if we want to use this code in 100 different sections with different angles, manual positioning will actually make our work extremely difficult. Commented 10 hours ago
  • @JafarManteghi If I don't see the correct design, I don't understand what I have to do. I'll leave the code here in case someone else might find it useful. Thank you for your feedback.
    – Sebastiano
    Commented 10 hours ago
  • 1
    I edited my question and updated the image so you can see exactly what I expected. Commented 10 hours ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.