Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to ask how the following command works:

\draw [] (0,0) to [out=20,in=120] (50,20) to [out=-60, in=110] (90,20);

I wonder what part .. to [out=20,in=120] .. makes. The result is a curve, but I don't know how to properly understand these parameters.

share|improve this question
5  
This is explained in the manual, section titled "The To Path Operation" (14.14 in my version). It would help if you explained what you don't understand from that explanation. –  Andrew Stacey Nov 29 '12 at 14:59
2  
Look at the pgfmanual version October 25, 2010 section 51.3 Curves (reached almost immediately searching "out="). –  Claudio Fiandrino Nov 29 '12 at 15:00
add comment

1 Answer

up vote 12 down vote accepted

From the pgfmanual :

If you write (a) to [out=135,in=45] (b) a curve is added to the path, which leaves at an angle of 135° at a and arrives at an angle of 45° at b. This is because the options in and out trigger a special path to be used instead of the straight line.

This actually allows you to bend paths between two points. The angles are specified with respect to the horizontal line, or, if the option relative is passed, with respect to the straight line between the two points.

Consider the simple example below : Example

The red curve is the result of (a) to [out=20, in=120] (b) as in your example. The angles specified by the out and in parameters are described on the picture. An easy way to remember the parameters is that you specify the angle by which your curve is going out of the source node, and entering in the target node.

To understand the difference induced by the option relative, have a look at the following two examples : first without the option relative, so absolute angles :

enter image description here

And now with relative angles :

enter image description here

Code

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (10,0) {b};
  \draw[dashed] (a) -- (b);
  \draw[dashed] (a) -- +(20:10cm);
  \draw[dashed] (b) -- +(120:4cm);
  \draw[dashed] (b) -- +(0:3cm);

  \draw (a) +(4,0)  arc (0:20:4);
  \draw (a) + (10:4.3) node {$20^{\circ}$};
  \draw (b) + (2,0) arc (0:120:2);
  \draw (b) + (60:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}

\clearpage

\begin{tikzpicture}
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (0,5) {b};
  \draw[dashed] (a) -- +(0:5cm);
  \draw[dashed] (a) -- +(20:10cm);
  \draw[dashed] (b) -- +(120:4cm);
  \draw[dashed] (b) -- +(0:3cm);

  \draw (a) +(4,0)  arc (0:20:4);
  \draw (a) + (10:4.3) node {$20^{\circ}$};
  \draw (b) + (2,0) arc (0:120:2);
  \draw (b) + (60:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}

\clearpage

\begin{tikzpicture}[relative]
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (0,5) {b};
  \draw[dashed] (a) -- (b);
  \draw[dashed] (a) -- +(110:10cm);
  \draw[dashed] (b) -- +(210:4cm);
  \draw[dashed] (b) -- +(90:3cm);

  \draw (a) +(0,2)  arc (90:110:2);
  \draw (a) + (100:2.3) node {$20^{\circ}$};
  \draw (b) + (0,2) arc (90:210:2);
  \draw (b) + (120:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}  


\end{document}

Acknowledgements

Thanks to Paul Gaborit for his remark regarding the option relative.

share|improve this answer
    
Without the option relative, the angles are absolute... –  Paul Gaborit Nov 29 '12 at 22:57
    
@PaulGaborit : Thanks, I completely forgot about that detail, and my example didn't help. I editted. –  T. Verron Nov 29 '12 at 23:18
    
Thank you. I suspected that somewhere in the manual will be, but I was frustrated that I can not find it. Once again, thank you all for your help. –  jafan Nov 30 '12 at 7:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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