# Tikz scaling seems to mess up arc (intersections)

This is probably a follow-up on these questions: Rotating tikzpicture messes up intersections an Why do these TikZ intersections scale incorrectly?

Let's use this MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=1]

\draw[name path=line 1] (1,1) --  +(-20:5);
\draw[name path=line 2] (1,-1) --  +(20:5);
\path[name intersections={of=line 1 and line 2}] (intersection-1) node (i){};
\fill (i) circle[radius=0.05cm];

\draw[blue] ([shift={(i.center)}]20:1) arc[radius=1, start angle=20, end angle= -20];
\end{tikzpicture}
\end{document}


This defines an intersection (i) and draws a circle (to check the position) and an arc between both lines. Works like a charm:

But when I increase the scaling to e.g. 2, it's not correct anymore:

Note that the black point is at the right position, so it's not the known bug from the two aforementioned threads.

Since manually setting the shift coordinates to (3.7, 0) produces a near-perfect output in both cases, the arc command itself must be ok.

I already tried the fixes from the other threads, like

\path[name intersections={of=line 1 and line 2,by={i}}];


and

\path[coordinate, name intersections={of=line 1 and line 2}] (intersection-1) node (i){};


but neither worked.

Any ideas?

• Give me another way to put that arc there and I'll gladly do so. But the problem doesn't seem to be the intersection but the arc. Well, somewhere in between. – jaytar Sep 4 '17 at 18:59

## 2 Answers

The culprit appears to be [shift=...]. Coordinates like (i.center) are given in absolute units, but shift seems to be applying the scale factor anyway. See the [shift only] key (page 359).

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=2]

\draw[name path=line 1] (1,1) --  +(-20:5);
\draw[name path=line 2] (1,-1) --  +(20:5);
\path[name intersections={of=line 1 and line 2}] (intersection-1) node (i){};
\fill (i) circle[radius=0.05cm];
\draw[blue] (i) ++(20:1) arc[radius=1, start angle=20, end angle= -20];

\draw[red] (i.center) -- ([shift=(i.center)] 0,0);& demonstrate difference
\draw[green, shift only] (i.center) -- ([shift=(i.center)] 0,0);% fix
\end{tikzpicture}
\end{document}

• In fact, it's because \begin{tikzpicture}[scale=2] is a canvas transformation while ([shift={ (i. center}}]20:1) is a coordinate transformation. See section 94.4 Coordinate Versus Canvas Transformations p 965 of the manual. – AndréC Sep 5 '17 at 7:14

Here is a solution using calc library with the minimum changes in your code and thinking

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}[scale=2.5]

\draw[name path=line 1] (1,1) --  +(-20:5);
\draw[name path=line 2] (1,-1) --  +(20:5);
\path[name intersections={of=line 1 and line 2}] (intersection-1) node (i){};
\fill (i) circle[radius=0.05cm];

\draw[red] ($(i.center)+(20:1)$) arc[radius=1, start angle=20, end angle= -20];

\end{tikzpicture}
\end{document}


Edit (Explanation of the problem)

The next code is using back and forth shifting commands either with x,y shift either with polar shift:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[scale=2.5]

\def\CenterX{0.}
\def\CenterY{0.}
\def\DistanceFTarget{1}
\def\AngleFTarget{30}
\def\DistanceSTarget{2}
\def\AngleSTarget{-30}
\node  at (\CenterX,\CenterY) (Center) {};
\fill[black] (Center) circle (0.2);
\pgfmathsetmacro\Xft{\CenterX+\DistanceFTarget*cos(\AngleFTarget)}
\pgfmathsetmacro\Yft{\CenterY+\DistanceFTarget*sin(\AngleFTarget)}
\pgfmathsetmacro\FTargetDistX{\Xft-\CenterX}
\pgfmathsetmacro\FTargetDistY{\Yft-\CenterY}
\pgfmathsetmacro\Xst{\CenterX+\DistanceSTarget*cos(\AngleSTarget)}
\pgfmathsetmacro\Yst{\CenterY+\DistanceSTarget*sin(\AngleSTarget)}
\pgfmathsetmacro\STargetDistX{\Xst-\CenterX}
\pgfmathsetmacro\STargetDistY{\Yst-\CenterY}

\draw[fill=blue] (\Xft,\Yft) node[right] {target1} circle (0.1);

\draw[->,ultra thick,red] (Center)--([shift=(Center)]\FTargetDistX,\FTargetDistY);
\draw[->,green,thin] (Center)--([shift=(Center)]\AngleFTarget:\DistanceFTarget);

\draw[fill=green] (\Xst,\Yst) node[right] {target2} circle (0.1);

\draw[->,ultra thick,orange] ([shift=(Center)]\STargetDistX,\STargetDistY) --(Center);
\draw[->,green,blue] ([shift=(Center)]\AngleSTarget:\DistanceSTarget) --(Center);

\end{tikzpicture}
\end{document}


and we get the next output:

The output is exactly what we expecting from the code, even if the picture is already shifted.

But if we change the center (that used for shifting to other point except of the current that was (0,0) -let's say to (1,3)-) and rescale (scale=1 is ok) we have the next result:

So the problem is that scaling (not xscaling or yscaling) does not respect our center of the shifting and has to be avoided.

• @JohnKormylo Yes... I am willing to edit and explain. But I would like some different answers like yours in this often situation. (I didn't found a duplicate yes... but probably exists) – koleygr Sep 4 '17 at 19:11
• Yes, obviously. Any idea why? Normally shift has no problem with transformations. – jaytar Sep 4 '17 at 19:16
• @JohnKormylo please add your solution. (I said with minimum changes because didn't thought your solution at that point. And yours doesn't require extra libraries... so my solution is not really the one with minimum changes) – koleygr Sep 4 '17 at 19:16
• I think that the main reason is that just shifting a point using polar coordinates like you did does not shifts the "current point of pencil" before starting to draw... moving (like @JohnKormylo did does the trick)... I will edit after test some things. May be this explanation is not good. It is just the idea I have before really test it. – koleygr Sep 4 '17 at 19:23
• Finally the reason is that shift command is respecting scaling only if the center is the (0,0) – koleygr Sep 4 '17 at 21:26