# \foreach dimension too big

I want to create an animation of satellites. I am using the code below. However I'd like it to run smoothly so I want to produce many frames. It turns out the maximum number of frames I can create via \foreach is 45. If I change to 46 I get the error Dimension too large.

So, how can I do 45+ \foreach loops?

\documentclass{beamer}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{frame}[fragile]
\frametitle{}

\begin{center}
\begin{tikzpicture}[scale=3.5]
\setbeamercovered{invisible}

\draw[thin] (0,0) circle (\IoOrbit);

\pgfmathsetmacro{\N}{45} %If 46 or more, then error.
\foreach \k in {0,1,...,\N}{
\pgfmathsetmacro{\theta}{360*\k/\N}
\pgfmathparse{int(\k+1)}
\onslide<\pgfmathresult>{
}
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

• It is not the \foreach it is the  \pgfmathsetmacro{\theta}{360*\k/\N} that causes the problem. No idea why – daleif Sep 29 '15 at 12:49
• Of course: 360*46 is too large for it to handle, but (360/N)*\k is not – daleif Sep 29 '15 at 12:51
• Reverse the order {360/\N*\k} – percusse Sep 29 '15 at 12:51
• Didn't imagine the order would be important, I guess it does because 360*46 is bigger than the allowed number latex handles? – PepeToro Sep 29 '15 at 12:54

In the calculation of \pgfmathsetmacro{\theta}{360*\k/\N} 360*\k easily becomes bigger than what LaTeX can handle. Reversing the multiplication order, solves this:
\pgfmathsetmacro{\theta}{360/\N*\k}