
수평 세그먼트를 수직 세그먼트로 애니메이션화하여 중간 지점을 중심으로 회전하고 변환하고 싶습니다. 아래 gif를 참조하세요.
왜 번역이 예상대로 작동하지 않는지 모르겠습니다. 보라색 세그먼트는 최종 파란색 위치로 이동해야 합니다.
MWE
\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}