I know that, by default, Tikz uses a "bend angle" of 30 degrees. From the mathematical point of view, what type of curve is used by Tikz when bending edges between nodes?
Asked
Active
Viewed 3,723 times
8
-
Can you give us an MWE to show what you mean by "bending"? I'm not familiar with that command... Thanks! – darthbith Jan 14 '15 at 12:33
1 Answers
17
Bent edges are constructed using the "curve to" operation so, as the manual states, they are cubic Bézier curves.
Internally it computes the relative angles, then adds the bend angle amount, and defines support points (defined by looseness key) and places to the path stream the following control sequence defined by
\edef\tikz@computed@path{%
.. controls \tikz@computed@start and \tikz@computed@end .. (\tikz@toto)%
}
You can control the angles by using bend left=<angle> and variants.
For finer control you can lookup in the manual the options looseness, in, out, in looseness and out looseness.
To show the control points you can use the following code:
\documentclass[tikz]{standalone}
\usetikzlibrary{calc,decorations.pathreplacing,shapes.misc}
\tikzset{
show control points/.style={
decoration={show path construction, curveto code={
\draw [blue, dashed]
(\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
node [at end, cross out, draw, solid, red, inner sep=2pt]{};
\draw [blue, dashed]
(\tikzinputsegmentsupportb) -- (\tikzinputsegmentlast)
node [at start, cross out, draw, solid, red, inner sep=2pt]{};
}
},
postaction=decorate
},
}
\begin{document}
\begin{tikzpicture}
\node(A){A} ++(2,0) node (B){B};
\draw (A) edge[bend left, show control points] (B)
edge[bend left=80, show control points] (B)
edge[looseness=.7,bend right, show control points] (B)
edge[looseness=.3,bend right, show control points] (B);
\end{tikzpicture}
\end{document}

Bordaigorl
- 15,135
-
Thanks @percusse for the comment on how the path is computed. I added few details on looseness and angle. – Bordaigorl Jan 15 '15 at 10:20