[Tex/LaTex] How to rotate a tikz rectangle about a specific axis


I am trying to create a beamer animation using tikz, but I can't even get basic rotating of a tikz image working as desired.

I have a rectangle specified by

\draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);

I would like to rotate this rectangle about the point (-1,.5) (which is near the bottom right corner of the rectangle). I've tried:

            \draw[rounded corners,dotted] (-3.5,0) rectangle (-0.5,2);}}

But this produces an error. If I just use the origin=c option, it compiles, but it rotates the rectangle about the point (0,0). I've also tried it with just the x=-1,y=.5 (without the origin option), and it fails to compile.

I have searched the documentation, which is where I learned about the options x=xdim and y=ydim. However, I can't find a single example demonstrating how these options should be used.

Any suggestions would be greatly appreciated.

Also, if there is a better command for rotating things that will be more suitable for use in a beamer animation, please let me know. Thanks!

Best Answer

TikZ has a rotate around={<angle>:<coordinate>} option:

\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);