# Rotation of Tikz diagram makes the size variable

I'm trying to animate a circle with some squares inside. I'd like the whole circle to rotate around its center. Somehow, the circle scaling is varing depending on the angle value. I've read a couple of posts and both animate and rotating manuals. Can someone please help me?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[autoplay,loop,nomouse]{animate}
\usepackage{rotating}

\newcommand{\obj}[1]{
\begin{turn}{#1}
\begin{tikzpicture}%[scale = 1]
%% Large circle
\node at (0,0) [rectangle,minimum size=1cm,fill=black,draw=black,shift={(3.5cm,3.5cm)},rotate=45] () {};
\node at (0,0) [rectangle, minimum size=.5cm,fill=black,draw=black,shift={(3cm,2cm)},rotate=25] () {};
\node at (0,0) [rectangle, minimum size=.25cm,fill=black,draw=black,shift={(1.75cm,1.5cm)},rotate=80] () {};
\end{tikzpicture}
\end{turn}
}

\begin{document}

\begin{animateinline}[controls]{72}%
\multiframe{72}{iAngle=0+5}{%
%iAngle = 80, 90, ..., 360 degrees
\obj{\iAngle}
}%
\end{animateinline}%

\end{document}


This is indeed a bit tricky because rotating a circle changes the bounding box. So I added an explicit bounding box. And then you do not need the rotating package here, you can rotate with TikZ but need to add transform shape to get the desired effect.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[autoplay,loop,nomouse]{animate}

\newcommand{\obj}[1]{
\begin{tikzpicture}
%% Large circle
\path[use as bounding box] (-2.5in,-2.5in) rectangle (2.5in,2.5in) ;
\begin{scope}[rotate=#1,transform shape]
\node at (3.5cm,3.5cm) [rectangle,minimum size=1cm,fill=black,draw=black,rotate=45] () {};
\node at (3cm,2cm) [rectangle, minimum size=.5cm,fill=black,draw=black,rotate=25] () {};
\node at (1.75cm,1.5cm) [rectangle, minimum size=.25cm,fill=black,draw=black,rotate=80] () {};
\end{scope}
\end{tikzpicture}
}

\begin{document}

\begin{animateinline}[controls]{72}%
\multiframe{72}{iAngle=0+5}{%
%iAngle = 80, 90, ..., 360 degrees
\obj{\iAngle}
}%
\end{animateinline}%

\end{document}


The result

is obtained using this answer, i.e. by adding export to the options of animate and then converting the multipage pdf to an animated gif.

In case you want only rotate the positions of the boxes, but not their orientation, try

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[autoplay,loop,nomouse]{animate}

\newcommand{\obj}[1]{
\begin{tikzpicture}
%% Large circle
\path[use as bounding box] (-2.5in,-2.5in) rectangle (2.5in,2.5in) ;
\begin{scope}[rotate=#1]
\node at (3.5cm,3.5cm) [rectangle,minimum size=1cm,fill=black,draw=black,rotate=45] () {};
\node at (3cm,2cm) [rectangle, minimum size=.5cm,fill=black,draw=black,rotate=25] () {};
\node at (1.75cm,1.5cm) [rectangle, minimum size=.25cm,fill=black,draw=black,rotate=80] () {};
\end{scope}
\end{tikzpicture}
}

\begin{document}

\begin{animateinline}[controls]{72}%
\multiframe{72}{iAngle=0+5}{%
%iAngle = 80, 90, ..., 360 degrees
\obj{\iAngle}
}%
\end{animateinline}%

\end{document}