
水平セグメントを垂直セグメントにアニメーション化し、その中心点を中心に回転させて移動させたいと思います。下の GIF を参照してください。
なぜ翻訳が期待どおりに機能しないのかわかりません。紫色のセグメントは最終的な青色の位置に移動するはずです。
ムウェ
\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\foreach \a in {0,1,...,10}{%
\begin{tikzpicture}
\useasboundingbox (-.2,-1.2) rectangle (4.2,2.2);
\draw[help lines] (0,0) grid (4,2);
\draw[red] (1,0) -- +(1,0);
\draw[blue] (2,1) -- +(0,1);
\draw[thick] (1,0)++(\a/10,\a/10) -- +(1,0); % translation
\draw[thick] let \p1=(1,0), \p2=(2,0) in [rotate around={-9*\a:(1.5,0)}] (\p1) -- (\p2) ; % rotation around mid point
\draw[thick,red!50!blue,shift={+(\a/10,\a/10)}] let \p1=(1,0), \p2=(2,0) in [rotate around={-9*\a:(1.5,0)}] (\p1) -- (\p2) ; % rotation + translation WRONG!!
\end{tikzpicture}
}
\end{document}
答え1
あなたの問題がよくわかりません。これがあなたが望んでいることですか?
\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\foreach \a in {0,1,...,10}{%
\begin{tikzpicture}
\useasboundingbox (-.2,-1.2) rectangle (4.2,2.2);
\draw[help lines] (0,0) grid (4,2);
\draw[red] (1,0) -- +(1,0);
\draw[blue] (2,1) -- +(0,1);
%\draw[thick] (1,0)++(\a/10,\a/10) -- +(1,0); % translation
%\draw[thick,green!20!black] let \p1=(1,0), \p2=(2,0) in [rotate around={-9*\a:(1.5,0)}] (\p1) -- (\p2) ; % rotation around mid point
\draw[thick,red!50!blue,shift={(\a/20,\a*1.5/10)}
]
let \p1=(1,0),
\p2=(2,0) in
[rotate around={-9*\a:(1.5,0)}]
(\p1) -- (\p2) ; % rotation + translation WRONG!!
\end{tikzpicture}
}
\end{document}
答え2
次の行を追加すべきだと思います:
\draw [green,rotate around={-9*\a:(2,0.1*\a)}] (1,0.1*\a) -- (2,0.1*\a); %Correct rotation
つまり、次のようになります。
\documentclass[tikz,margin=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\foreach \a in {0,1,...,10}{%
\begin{tikzpicture}
\useasboundingbox (-.2,-1.2) rectangle (4.2,2.2);
\draw[help lines] (0,0) grid (4,2);
\draw[red] (1,0) -- +(1,0);
\draw[blue] (2,1) -- +(0,1);
\draw[thick] (1,0)++(\a/10,\a/10) -- +(1,0); % translation
\draw[thick] let \p1=(1,0), \p2=(2,0) in [rotate around={-9*\a:(1.5,0)}] (\p1) -- (\p2) ; % rotation around mid point
\draw[thick,red!50!blue,shift={+(\a/10,\a/10)}] let \p1=(1,0), \p2=(2,0) in [rotate around={-9*\a:(1.5,0)}] (\p1) -- (\p2) ; % rotation + translation WRONG!!
%\draw [magenta,rotate around={-9*\a:(2,0)}] (1,0) -- (2,0); %rotation
%\draw [yellow] (1,0.1*\a) -- (2,0.1*\a);%translation vertical
\draw [green,rotate around={-9*\a:(2,0.1*\a)}] (1,0.1*\a) -- (2,0.1*\a); %Correct rotation
\end{tikzpicture}
}
\end{document}