![如何绕特定轴旋转 tikz 矩形?](https://linux22.com/image/246455/%E5%A6%82%E4%BD%95%E7%BB%95%E7%89%B9%E5%AE%9A%E8%BD%B4%E6%97%8B%E8%BD%AC%20tikz%20%E7%9F%A9%E5%BD%A2%EF%BC%9F.png)
我正在尝试使用 tikz 创建 beamer 动画,但我甚至无法按预期完成 tikz 图像的基本旋转。
我有一个指定的矩形
\draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);
我想绕点 (-1,.5)(靠近矩形的右下角)旋转此矩形。我尝试过:
{\rotatebox[origin=c,x=-1,y=.5]{130}{
\draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);}}
但这会产生错误。如果我只使用该origin=c
选项,它会编译,但它会围绕点 (0,0) 旋转矩形。我也尝试过只使用x=-1,y=.5
(没有原点选项),但编译失败。
我搜索了文档,从中我了解了选项x=xdim
和y=ydim
。但是,我找不到一个示例来演示如何使用这些选项。
任何建议将不胜感激。
另外,如果有更好的命令来旋转物体,更适合在投影机动画中使用,请告诉我。谢谢!
答案1
TikZ 有一个rotate around={<angle>:<coordinate>}
选项:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill (-1,0.5) circle [radius=2pt];
\draw[rounded corners] (-3.5,0) rectangle (-0.5,2);
\draw[rounded corners,red,rotate around={30:(-1,0.5)}] (-3.5,0) rectangle (-0.5,2);
\end{tikzpicture}
%
\end{document}