圆形与拱形的缩短——正常还是错误?

圆形与拱形的缩短——正常还是错误?

当我使用 pgf 中的圆弧绘制拱门时,拱门路径精确地适合相应(即具有相同半径)圆的路径(附图中的黑底红线)。当我将缩短应用于圆弧路径时,它不适合,变得扭曲(蓝线与黑线/红线)。这是正常的还是只是一个错误?期望缩短的圆弧路径精确地适合圆路径是不正确的?如果这不是一个错误,如何解释?

在此处输入图片描述

绘图的 Latex 代码:

\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

\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}

在此处输入图片描述

在此处输入图片描述

答案2

TikZ 中的曲线始终是贝塞尔曲线,当 TikZ 缩短贝塞尔曲线时,它会沿切线方向移动端点。对于圆弧,这会使其变形,使其不再是圆弧。

我的spath3库实现了一种沿路径长度缩短路径的方法。它不保证精确的缩短时的长度,但保证缩短的路径与原始路径重合。

\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}

请注意,在撰写本文时,我注意到库中有一个错误,这意味着它需要来自的版本github上班。

缩短弧

相关内容