It seems that the option rounded corners
(especially with larger radii) and arc
s in TikZ do not always go well together. In general, the exact same path with rounded corners applied does not exactly overlap the other path that does not use rounded corners. I assume that this is because the rounded corner hits an arc.
Is there a feasible way to get such rounded corners (preferably with different radii) without this distorting effect? I already tried to shorten the arc or temporarily switch off rounded corners, but I still often get rounded corners that don’t nicely merge with the arc and I don’t really like to cobble together the path like this.
\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[
pshift/.style args={(#1:#2)}{%
shift={({sin(-#1)*#2},{cos(-#1)*#2})}
},
line/.style={%
line width=5pt
},
spy using outlines={%
circle,
magnification=5,
size=2cm,
connect spies
}
]
\begin{scope}[opacity=.5]
\draw[line, green!75!black]
(30:3cm)
-- (30:6cm)
arc (30:60:6cm)
-- (60:9cm)
arc (60:90:9cm)
-- (90:3cm);
\draw[line, green!50!black]
([pshift={(30:10pt)}]30:3cm)
-- ([pshift={(30:10pt)}]30:{6cm-10pt})
arc ({30+asin(10pt/(6cm-10pt))}:{60+asin(10pt/(6cm-10pt))}:{6cm-10pt})
-- ([pshift={(60:10pt)}]60:{9cm-10pt})
arc ({60+asin(10pt/(9cm-10pt))}:{90-asin(10pt/(9cm-10pt))}:{9cm-10pt})
-- ([pshift={(90:-10pt)}]90:3cm);
\end{scope}
\draw[line, red!75!black, rounded corners=12pt]
(30:3cm)
-- (30:6cm)
[rounded corners=4pt]
arc (30:60:6cm)
[rounded corners=12pt]
-- (60:9cm)
arc (60:90:9cm)
-- (90:3cm);
\draw[line, red!50!black, rounded corners=4pt]
([pshift={(30:10pt)}]30:3cm)
-- ([pshift={(30:10pt)}]30:{6cm-10pt})
[rounded corners=12pt]
arc ({30+asin(10pt/(6cm-10pt))}:{60+asin(10pt/(6cm-10pt))}:{6cm-10pt})
[rounded corners=4pt]
-- ([pshift={(60:10pt)}]60:{9cm-10pt})
arc ({60+asin(10pt/(9cm-10pt))}:{90-asin(10pt/(9cm-10pt))}:{9cm-10pt})
-- ([pshift={(90:-10pt)}]90:3cm);
\spy on (57.5:{6cm-10pt}) in node at (60:4cm);
\spy on (85:9cm) in node at (75:7cm);
\end{tikzpicture}
\end{document}
An example with temporarily disabled rounded corners, better but still a bit off:
\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{spy}
\begin{document}
\begin{tikzpicture}[
pshift/.style args={(#1:#2)}{%
shift={({sin(-#1)*#2},{cos(-#1)*#2})}
},
line/.style={%
line width=5pt
},
spy using outlines={%
circle,
magnification=5,
size=2cm,
connect spies
}
]
\begin{scope}[opacity=.5]
\draw[line, green!75!black]
(60:6cm)
-- (60:9cm)
arc (60:90:9cm)
-- (90:6cm);
\end{scope}
\draw[line, blue!75!black, rounded corners=12pt]
(60:6cm)
-- (60:9cm)
[rounded corners=0pt]
-- ([pshift={(60:12pt)}]60:9cm)
arc (({60+asin(12pt/(9cm-12pt))}:({90-asin(12pt/(9cm-12pt))}:9cm)
[rounded corners=12pt]
-- (90:9cm)
-- (90:6cm);
\spy on (85:9cm) in node at (75:7cm);
\spy on (65:9cm) in node at (75:11cm);
\end{tikzpicture}
\end{document}
\draw[newrounded corners=10mm]
will work.