从Tikz:在旋转的范围内画一条直线,Paul Gessler 指出,以(P)
与初始旋转相反的方向旋转标记坐标会抵消它。但是,如果我们这样做到一定程度,它就不起作用了。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate = 45]
\draw (-0.5cm, -1cm) rectangle (0.5cm, -2cm) coordinate (P);
\draw[rotate = -45] (P) -- +(0, -1);
\draw[rotate = -45] (0.5cm, -2cm) -- +(0, -1);
\end{scope}
\end{tikzpicture}
\end{document}
考虑到(P)
和(-0.5cm, -2cm)
是同一位置,为什么使用坐标点而不是名称不起作用?
答案1
除非您明确说明,否则节点不会移动。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate = 45]
\draw (-0.5cm, -1cm) rectangle (0.5cm, -2cm) coordinate (P);
\draw[rotate = -45,yellow] (P) -- ++(0, -1);
\draw[rotate = -45,very thick,blue!50] (0.5cm, -2cm) -- ++(0, -1);
\draw[rotate = -45,red] ([rotate = -45]P) -- ++(0, -1);
\end{scope}
\draw[rotate = -45,yellow,dashed] (P) -- ++(0, -1);
\draw[rotate = -45,very thick,blue!50,dashed] (0.5cm, -2cm) -- ++(0, -1);
\draw[rotate = -45,red,dashed] ([rotate = -45]P) -- ++(0, -1);
\end{tikzpicture}
\end{document}