# ! Dimension too large in pgf

I have no familiarity with TEX, PGF, etc -- but somebody was kind enough to offer me code to produce something I'd like to use. Unfortunately, I get a Dimension too large error when I run the following code. I am truly sorry for my inexperience -- and would appreciate any help I can get to correct the error:

\documentclass[12pt]{article}

\usepackage[paperwidth=200pt, paperheight=200pt,margin=12pt]{geometry}
\usepackage{color,tikz,ifthen,animate}

\begin{document}

% This code will simulate a pitch based on the 9-parameter PITCHf/x model.
% Written by Matthew Mata, November 2014.

\thispagestyle{empty}

% Set the counter
\newcounter{m}
\setcounter{m}{0}

% Set the 9 PITCHf/x parameters
\pgfmathsetmacro{\xo}{-2.463}
\pgfmathsetmacro{\yo}{50}
\pgfmathsetmacro{\zo}{5.419}
\pgfmathsetmacro{\vxo}{11.609}
\pgfmathsetmacro{\vyo}{-144.84}
\pgfmathsetmacro{\vzo}{-7.734}
\pgfmathsetmacro{\ax}{-19.761}
\pgfmathsetmacro{\ay}{34.528}
\pgfmathsetmacro{\az}{-16.898}
\pgfmathsetmacro{\g}{-32.174}

% Set the time to the plate
\pgfmathsetmacro{\r}{\vyo/\ay}
\pgfmathsetmacro{\s}{2*(\yo-(17/12))/\ay}
\pgfmathsetmacro{\tplate}{-\r - sqrt(\r*\r - \s)}

% Set time of release
\pgfmathsetmacro{\u}{2*(\yo-55)/\ay}
\pgfmathsetmacro{\trel}{-\r - sqrt(\r*\r - \u)}

% Set time from release to plate
\pgfmathsetmacro{\t}{\tplate - \trel}

% Set the number of frames
\pgfmathtruncatemacro{\frames}{int(round(\t*60)+1)}

% Set the time increment
\pgfmathsetmacro{\dt}{\t/(\frames-1)}

% Create the animation
\begin{center}
\begin{animateinline}[poster=first,loop,controls]{60}
\whiledo{\them < \frames}{
\begin{tikzpicture}
% Clip off anything out of frame
\clip (-3,0) rectangle (3,5);
% Sky
\shade[top color = blue!50!white, bottom color = blue!10!white] (-3,5) -- (3,5) -- (3,2.5) -- (-3,2.5) -- cycle;
% Grass
\shade[top color = green!50!black, bottom color = green!70!black] (-3,0) -- (3,0) -- (3,2.447) to [out=179, in =0] (0,2.454) to [out=180, in=1] (-3,2.447) -- (-3,0);
% Batter's Eye
\shade[top color = green!60!black, bottom color = green!30!black] (-0.541,3.176) -- (0.541,3.176) -- (0.541,2.5) -- (-0.541,2.5) -- cycle;
% Bleachers
\draw[fill = blue!50!black] (-3,3.274) to [out=-1, in=180] (-0.541,3.176) -- (-0.541,2.5) -- (-3,2.5) -- cycle;
\draw[fill = blue!50!black] (3,3.274) to [out=181, in=0] (0.541,3.176) -- (0.541,2.5) -- (3,2.5) -- cycle;
% Outfield Wall
\shade[top color = green!40!black, bottom color = green!20!black] (-3,2.447) -- (-3,2.659) to [out=-1, in=180] (0,2.639) to [out=0, in=181] (3,2.659) -- (3,2.447) to [out=179, in =0] (0,2.454) to [out=180, in=1] (-3,2.447);
% Yellow Line
\draw[yellow] (-3,2.659) to [out=-1, in=180] (0,2.639) to [out=0, in=181] (3,2.659);
% Mound
\shade[top color = brown!90!black, bottom color = brown!70!black] (-1.014,2.218) to [out=10, in=180] (0,2.312) to [out=0, in=170] (1.014,2.218) to [out=185, in=0] (0,2.174) to [out = 180, in=355] (-1.014,2.218);
% Pitching Rubber
\draw [white] (-0.113,2.312) -- (0.113,2.312);
% Time increment between pitches
\pgfmathsetmacro{\tinc}{\dt*\them + \trel};
% Current flight time of the pitch
\pgfmathsetmacro{\time}{\dt*\them};
% Location of the pitch at the given time
\pgfmathsetmacro{\xraw}{0.5*\ax*\tinc*\tinc + \vxo*\tinc + \xo};
\pgfmathsetmacro{\yraw}{0.5*\ay*\tinc*\tinc + \vyo*\tinc + \yo};
\pgfmathsetmacro{\zraw}{0.5*\az*\tinc*\tinc + \vzo*\tinc + \zo};
% Velocity of the pitch at the given time
\pgfmathsetmacro{\vx}{\ax*\tinc + \vxo};
\pgfmathsetmacro{\vy}{\ay*\tinc + \vyo};
\pgfmathsetmacro{\vz}{\az*\tinc + \vzo};
\pgfmathsetmacro{\vel}{sqrt((15*\vx/22)*(15*\vx/22) + (15*\vy/22)*(15*\vy/22) + (15*\vz/22)*(15*\vz/22))};
% Projection of the pitch into the strike zone
\pgfmathsetmacro{\xproj}{\vx*(\tplate - \tinc) + \xraw};
\pgfmathsetmacro{\zproj}{0.5*\g*(\tplate - \tinc)*(\tplate - \tinc) + \vz*(\tplate - \tinc) + \zraw};
% Distance to the catcher's viewpoint
\pgfmathsetmacro{\xdist}{\xraw};
\pgfmathsetmacro{\ydist}{\yraw + (73/12)};
\pgfmathsetmacro{\zdist}{\zraw - 2.5};
% Spherical coordinates of the pitch
\pgfmathsetmacro{\theta}{atan2(\xdist,\ydist)};
% Location of the pitch from the catcher's perspective
% Plot the pitch
% Plot the strike zone
\draw[black!85!white] (-17/24,1.5) -- (17/24,1.5) -- (17/24,3.5) -- (-17/24,3.5) -- cycle;
% Plot the projection
% Display the diagnostics
\node[above right] at (-3,4.4) {Dist.: };
\node[above left] at (-1,4.4) {\pgfmathprintnumber[precision=1,fixed]{\yraw}};
\node[above right] at (-1.2,4.4) {ft};
\node[above right] at (0,4.4) {Vel.: };
\node[above left] at (2.1,4.4) {\pgfmathprintnumber[precision=1,fixed]{\vel}};
\node[above left] at (3,4.325) {mph};
\node[above right] at (-3,0) {Time: };
\node[above left] at (-0.9,0) {\pgfmathprintnumber[precision=2,fixed]{\time}};
\node[above right] at (-1.1,0) {sec};
\end{tikzpicture}
\stepcounter{m}
\ifthenelse{\them < \frames}{
\newframe
}
{
\end{animateinline} \relax
}
}
\end{center}

\end{document}

• I don't know if this constitutes for a fix because I don't know what to see but if you go to the line below Plot the pitch comment and put pts after the coords (\xscale pt,\zscale pt), it compiles. The reason is that \xscale hits something more than 1400 and without any units that 14 meters which is beyond any TeX dimension. And send my regards to the author of this code. That's some patience right there to code this all up. – percusse Dec 16 '14 at 17:23
• That worked, thank you very much. I appreciate it. – Many Thanks Dec 16 '14 at 18:30
• Well, might have been a little premature. The image is supposed to be a moving ball to a target. . . but only the target appears when I run it (no ball) and the whole thing seems frantic. Might the "pt" have influenced that at all? Or should I be looking elsewhere (THANK YOU)? – Many Thanks Dec 16 '14 at 19:10
• It should only run in Acrobat by the way. And I also only see a red circle moving towards the pitcher but I have no idea what it should look like. Have you seen it actually working? – percusse Dec 16 '14 at 19:20
• Yeahh -- it's from this (tremendous) article: fangraphs.com/community/… – Many Thanks Dec 16 '14 at 20:03