OK, so I'm guessing that there's a cog centered at every local min (or max,) and that they are slightly off-center to allow the "stretching"... but what determines the number of teeth on each cog? I just can't wrap my brain around that--or how cool this is! Nicely done.
One central wheel was round and not "stretched". The rest are its copies aligned using polar coordinates in hyperbolic plane. There are two kinds of wheels - 10-cog (rotating clockwise) and 8-cog (rotating counter-clockwise). 8-cog wheels are actually also "copied" from 10-cog ones.
...But actually the picture is not as complex as it may seem.