使 TikZ 使用旋转时提供新点

使 TikZ 使用旋转时提供新点

所以我有以下代码

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, petri, topaths, automata, calc, patterns, angles, quotes}

\begin{document}

\begin{tikzpicture}
\draw (-1.4,-1.125) to [out = 160, in = 20]
(-1.85,-1.1) to[out =60,in = 270]
(-1.7,-0.35) to
(-0.55,-0.35) to
(-1.55,0.4) to
(-1.4,1) to[out = 290, in = 160]
(-0.6,0.25) to[out = 90,in=285]
(-0.45,0.9) to
(-0.75,0.75) to (-1.34,1.352)
to (-0.75,2.05)
to[out=-30,in = 100] (0.75,0.75)
to[out=45,in=270] (1.1,1.325);

\begin{scope}[rotate around ={(90:(1.1,1.325)}]
\draw (-1.4,-1.125) to [out = 160, in = 20]
(-1.85,-1.1) to[out =60,in = 270]
(-1.7,-0.35) to
(-0.55,-0.35) to
(-1.55,0.4) to
(-1.4,1) to[out = 290, in = 160]
(-0.6,0.25) to[out = 90,in=285]
(-0.45,0.9) to
(-0.75,0.75) to (-1.34,1.352)
to (-0.75,2.05)
to[out=-30,in = 100] (0.75,0.75)
to[out=45,in=270] (1.1,1.325);
\end{scope}

\node[circle, fill = red, inner sep = 1pt] at (1.1,1.325){};

\end{tikzpicture}
\end{document}

通过围绕红点将第一条路径旋转 90 度,它为我生成了两条路径。有没有办法让我轻松地将它们放入一条连续的路径中,这样它们都在同一个 \draw ; 部分内。我在想,如果我能让 LaTeX 为我提供围绕点旋转后的新坐标,我就可以以此为基础进行操作了。

答案1

当然,您只需添加[rotate around ={(90:(1.1,1.325)}]路径,其后的所有内容都会被旋转。

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (-1.4,-1.125) to [out = 160, in = 20]
(-1.85,-1.1) to[out =60,in = 270]
(-1.7,-0.35) to
(-0.55,-0.35) to
(-1.55,0.4) to
(-1.4,1) to[out = 290, in = 160]
(-0.6,0.25) to[out = 90,in=285]
(-0.45,0.9) to
(-0.75,0.75) to (-1.34,1.352)
to (-0.75,2.05)
to[out=-30,in = 100] (0.75,0.75)
to[out=45,in=270] (1.1,1.325)
[rotate around ={(90:(1.1,1.325)}]
 (-1.4,-1.125) to [out = 160, in = 20]
(-1.85,-1.1) to[out =60,in = 270]
(-1.7,-0.35) to
(-0.55,-0.35) to
(-1.55,0.4) to
(-1.4,1) to[out = 290, in = 160]
(-0.6,0.25) to[out = 90,in=285]
(-0.45,0.9) to
(-0.75,0.75) to (-1.34,1.352)
to (-0.75,2.05)
to[out=-30,in = 100] (0.75,0.75)
to[out=45,in=270] (1.1,1.325);
\node[circle, fill = red, inner sep = 1pt] at (1.1,1.325){};
\end{tikzpicture}
\end{document}

在此处输入图片描述

由于这是两次相同的路径,您可能正在寻找insert path

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[my path/.style={insert path={(-1.4,-1.125) to [out = 160, in = 20]
(-1.85,-1.1) to[out =60,in = 270]
(-1.7,-0.35) to
(-0.55,-0.35) to
(-1.55,0.4) to
(-1.4,1) to[out = 290, in = 160]
(-0.6,0.25) to[out = 90,in=285]
(-0.45,0.9) to
(-0.75,0.75) to (-1.34,1.352)
to (-0.75,2.05)
to[out=-30,in = 100] (0.75,0.75)
to[out=45,in=270] (1.1,1.325)}}]
\draw[my path,rotate around ={(90:(1.1,1.325)},my path];
\node[circle, fill = red, inner sep = 1pt] at (1.1,1.325){};
\end{tikzpicture}
\end{document}

相关内容