6

When I draw arches using arc in pgf, the arch path precisely fits on the path of the corresponding (ie having the same radius) circle (red on black in the attached figure). When I apply shorten to the arc path, it does not fit, becomes distorted (blue line vs black/red). Is this normal or only a bug? Expecting a shortened arc path which fits precisely on the circle path is not correct? If this is not a bug, how can it be explained?

enter image description here

Latex code of the drawing:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\coordinate (C) at (4,4);
\draw[line width=2pt] (C) circle (4cm);
\draw[very thick,red] (C) ++(170:4cm) arc (170:60:4cm);
\draw[very thick,blue,shorten <=20pt,shorten >=20pt] (C) ++(170:4cm) arc (170:60:4cm);
\end{tikzpicture}
\end{document}
1
  • 1
    This is probably caused by the control points used, it looks to me like the end points are still at the original angle, which of course is wrong for a shorter arc. This is because (I guess) tikz applies a linear scaling of the coordinates of the endpoints (apparently not of the control points) instead of radially cutting of a part. Not sure how to fix this, perhaps you could apply a clip to the arc instead?
    – hugovdberg
    Commented Apr 3, 2014 at 18:31

2 Answers 2

3
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[yellow!80!black,ultra thick,-latex] (90:4cm)--+(-5mm,0)--+(45mm,0);
\foreach\x[evaluate=\x as \xi using 2.5*\x] in {0,4,...,40}
\draw[blue!\xi!red,shorten >=\x mm] (0,0)++(0:4cm) arc (0:90:4cm);
\end{tikzpicture}

\begin{tikzpicture}
\node[text width=2.6cm,above] (a) {A curve ending with a tangent angle opposite of green line};
\draw[latex-,thick] (0,0) arc (70:20:4cm);
\draw[thick,green,-latex] (0,0) -- ++(160:-2.5cm) 
          node[align=right,right] {shortening\\direction};

% Shortens
\draw[blue!10,shorten <=50pt] (0,0) arc (70:20:4cm);
\draw[blue!10,shorten <=70pt] (0,0) arc (70:20:4cm);
% Negative shortening means extension
\draw[red!10,thin,shorten <=-30pt] (0,0) arc (70:20:4cm);
\end{tikzpicture}
\end{document}

enter image description here

enter image description here

3
  • An artificial rainbow with limited colors? ;)
    – user11232
    Commented Apr 4, 2014 at 0:11
  • @percusse---So you're demonstrating the longer the path shortened by, the more distorted it is, even going to the extreme. But what is your conclusion?
    – bcsikos
    Commented Apr 4, 2014 at 8:24
  • @percusse "shortens the path based on the final angle going backwards": I cannot comprehend this unfortunately, especially "final angle going backwards" I don't understand.
    – bcsikos
    Commented Apr 4, 2014 at 15:22
2

Curves in TikZ are always Bézier curves underneath, and when TikZ shortens a Bézier curve it does so by shifting the end point in the direction of the tangent. In the case of the arc, this distorts it so that it is no longer an arc.

My spath3 library implements a method for shortening a path along its length. It doesn't guarantee exact lengths when shortening, but does guarantee that the shortened path coincides with the original path.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/169401/86}
\usepackage{tikz}
\usetikzlibrary{spath3}
\begin{document}
\begin{tikzpicture}
\coordinate (C) at (4,4);
\draw[line width=4pt] (C) circle[radius=4cm];
\draw[line width=3pt,red] (C) ++(170:4cm) arc[start angle=170, end angle=60, radius=4cm];
\draw[line width=2pt,blue,shorten <=20pt,shorten >=20pt] (C) ++(170:4cm) arc[start angle=170, end angle=60, radius=4cm];
\draw[line width=1pt,green] (C) ++(170:4cm) arc[start angle=170, end angle=60, radius=4cm] [spath/remove empty components=current,spath/shorten at both ends={current}{20pt}];
\end{tikzpicture}
\end{document}

Note that at time of writing, I noticed a bug in the library that means that this needs the version from github to work.

Shortened arc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .