31

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.

  • 2
    Change right to left and see what happens! – Sigur Oct 28 '13 at 14:07
45

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}
  • Is there a rationale behind this wording? I'd have preferred to have a curve right option instead of bend right = curve left. – Bakuriu Oct 28 '13 at 18:59
  • 5
    @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}} – Jake Oct 28 '13 at 19:26
7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.