Meaning of bend right or left in TikZ?

39,127

Solution 1

The arrow is curving to the left, but you are bending it to the right:

\documentclass[border=5pt]{article}
\usepackage{tikz}
\begin{document}
\centering 
\begin{tikzpicture}
\draw [thick, -latex] (0,0) to (0,3);
\end{tikzpicture}

\begin{tikzpicture}[trim left=0pt, trim right=0pt]
\draw [thick, -latex] (0,0) to [bend right] (0,3);
\draw [line width=5pt, -stealth, red!80!blue] (-1,1.5) -- (0.4,1.5);
\end{tikzpicture}


\end{document}

Solution 2

Intead of drawing a straight line from (waiting) to (enter critical), you draw a bended line to the right of the expected direction.

Additionally, since the expected angle is 45-degrees, if you bend it another 45-degrees, the lines appears as departing on a 90-degrees angle.

Try this:

  • Draw the line without the bending, you'll see the "expected" line
  • Use the bend left option, to compare
  • play around with the bending angles.
Share:
39,127

Related videos on Youtube

wdg
Author by

wdg

Updated on October 29, 2020

Comments

  • wdg
    wdg about 3 years

    The following code actually comes from the PGF manual. It works fine, but I have a difficult time in understanding it (I'm new to TikZ)

    \documentclass{article} %  say
    \usepackage{tikz}
    \usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
    \begin{document}
    \begin{tikzpicture}
    [place/.style={circle,draw=blue!50,fill=blue!20,thick,
                 inner sep=0pt,minimum size=6mm},
    transition/.style={rectangle,draw=black!50,fill=black!20,thick,
                      inner sep=0pt,minimum size=4mm}]
    \node[place] (waiting) {};
    \node[place] (critical) [below=of waiting] {};
    \node[place] (semaphore) [below=of critical]{};
    \node[transition] (leave critical) [right=of critical]{};
    \node[transition] (enter critical) [left=of critical]{};
    \draw [->] (enter critical) to                 (critical);
    \draw [->] (waiting)        to [bend right=45] (enter critical);
    \draw [->] (enter critical) to [bend right=45] (semaphore);
    \end{tikzpicture}
    \end{document}
    

    The above will give me something like this:

    enter image description here

    My question is: how shall I understand the two bend right? Regarding the long arrow starting from the circle at the top to square on the left side, it seems more like bending left to me. In what sense does it bend right? The same problem with the long arrow starting from the square on the left side to the circle at the bottom.

    • Sigur
      Sigur about 10 years
      Change right to left and see what happens!
  • Bakuriu
    Bakuriu about 10 years
    Is there a rationale behind this wording? I'd have preferred to have a curve right option instead of bend right = curve left.
  • Jake
    Jake about 10 years
    @Bakuriu: You can define curve left and curve right styles for that: \tikzset{curve left/.style={bend right=#1}, curve right/.style={bend left=#1}}