1

This document

\documentclass[DIV=16]{scrartcl}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\hrule
\begin{center}
\begin{tikzpicture}[scale=.3]
    \draw[domain=-1:5] plot (\x,{0.5*\x*\x*(\x-3)});
\end{tikzpicture}
\end{center}
\hrule
\begin{center}
\begin{tikzpicture}[scale=.3]
    \draw (-1,-2) .. controls (1,7) and (3,-20) .. (5,25);
\end{tikzpicture}
\end{center}
\hrule
\end{document}

produces this output: two cubic polynomials So, the second picture has a much larger bounding box, which is probably due to the control points. Is there a possibility to force tikz to calculate the real extrema rather than just looking at the terminal points and the control points?

Edit: The bounding box shall automatically be correct WITHOUT adding new points to the curve. It is okay for me, if you say that there is no possibility without changing tikz itself. This just means that I can ask the tikz development for this feature without overlooking something obvious.

  • 1
    It isn't possible as that's a complicated calculation for a general bézier curve. Take a look at https://tex.stackexchange.com/q/43621/86 and the questions linked there to see if you can find an acceptable workaround. I suspect this question will end up a duplicate of one of those, but I'm not sure which one is best for you. – Andrew Stacey Dec 18 '17 at 21:30
  • 1
  • @PaulGaborit I am aware that I can add further points (extrema in the ideal case), but I would like tikz to calculate the bounding box correctly without adding further points. – Linus Romer Dec 19 '17 at 13:38
  • @LoopSpace Is the calculation really complicated? Aren't dx/dt and dy/dt quadratic functions of t and therefore the local extrema the roots of quadratic equations? – Linus Romer Dec 19 '17 at 13:41
  • @LinusRomer You also need to take into account the local transformation: since the bounding box is always a rectangle with respect to the page, you need to calculate the extrema with respect to the global horizontal and vertical. So while it's not impossible, it's not a cheap calculation and given the number of béziers in a typical drawing, probably not worth the overhead for most pictures. – Andrew Stacey Dec 19 '17 at 14:16
  • So I guess the answer is really "no, there is no such possibility". Thereupon I have opened a feature request here: https://sourceforge.net/p/pgf/feature-requests/109/ Thanks for the links to the related threads. – Linus Romer Dec 19 '17 at 17:36

0 Answers0