8

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?

  • 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
16

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}

control points

| improve this answer | |
  • 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

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.