我尝试将点(B0)
逆时针旋转 90 度(A1)
,然后循环以获得(B\k)
和(A\k)
。我做错了什么?
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=5]
\coordinate (A0) at (0,0);
\coordinate (B0) at (0,1);
\path[draw,blue](A0)--(B0)coordinate[pos=.382](A1);
\coordinate(B1)at([rotate around={90:(A1)}]B0);
\draw[red](A1)--(B1);
\end{tikzpicture}
\end{document}
红色是我使用
([rotate around={90:(A1)}]B0)
我希望看到的是绿色。
答案1
像这样?
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{tikz}
\begin{document}
\center
\begin{tikzpicture}[scale=5]
\coordinate (A0) at (0,0);
\node (A) at (A0) {A};
\coordinate (B) at (0,1);
\foreach \k in {0,90,180,270}
{
\node (B\k) at ([rotate around={\k:(A0)}]B) {B\k};;
}
\end{tikzpicture}
\end{document}
答案2
看来问题的根源在于缩放。它将旋转中心的坐标缩放两次。第一次是在定义 (A1) 时,第二次是在旋转时(您可以通过显式符号 {90:(0,1.91)} 看到这一点)
\begin{tikzpicture}
\tikzstyle{subj} = [circle, minimum width=0.2mm, draw,inner sep=1mm]
\coordinate (A0) at (0,0);
\coordinate (B0) at (0,5);
\path[draw,blue](A0)--(B0) coordinate[pos=.382](A1);
\coordinate(B1)at ([rotate around={90:(A1)}]B0);
\draw[red](A1)--(B1);
\node[subj] at (A0) {A0};
\node[subj] at (B1) {B1};
\node[subj] at (B0) {B0};
\node[subj] at (A1) {A1};
\end{tikzpicture}
答案3
好的,我明白了。这个问题很有帮助:
现在我的富含循环的代码是这样的并且运行完美:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.arrows,chains,positioning,intersections,decorations.text}
\usetikzlibrary{calc}
\usepackage{ifthen}
\begin{document}
%
\center
\begin{tikzpicture}[scale=15]
\coordinate (A0) at (0,0);
\coordinate (B0) at (0,1);
\draw[blue](A0)--(B0);
\foreach \k[evaluate={\ki=int(\k-1)}] in {1,...,7}
{\path(A\ki)--(B\ki)coordinate[pos=.382](A\k);
\draw[red] let \p\ki=(A\ki), \p\k=(A\k) in (\p\k)--([rotate around={90:(\p\k)}]B\ki)coordinate(B\k);
\node[draw] at (B\k){B\k};}
\end{tikzpicture}
\end{document}