4

I need some help to modify the \gear macro of this answer in order to be able to fill the drawn gear with a solid color.

I've tried to move the \draw command outside the loop, but it does not work as expected (missing semicolon???):

\newcommand{\gear}[3]{%
    \def\modu{#1}
    \def\Zb{#2}
    \def\AngleA{#3}

    \pgfmathsetmacro{\Rpr}{\Zb*\modu/2}
    \pgfmathsetmacro{\Rb}{\Rpr*cos(\AngleA)}
    \pgfmathsetmacro{\Rt}{\Rpr+\modu}
    \pgfmathsetmacro{\Rp}{\Rpr-1.25*\modu}
    \pgfmathsetmacro{\AngleT}{pi/180*acos(\Rb/\Rt)}
    \pgfmathsetmacro{\AnglePr}{pi/180*acos(\Rb/\Rpr)}
    \pgfmathsetmacro{\demiAngle}{180/\Zb}
    \pgfmathsetmacro{\Angledecal}{(\demiAngle-2*\AnglePr)/2}

    \draw[fill=black!20] \foreach \zz in{1,2,...,\Zb}{
         ({(\zz))/\Zb*360-\Angledecal}:\Rb)
            -- (\zz/\Zb*360-\Angledecal:\Rp)
            to[bend right=\demiAngle] (\zz/\Zb*360+\Angledecal:\Rp)
            -- plot[domain=-0:\AngleT,smooth,variable=\t]
                ({{180/pi*(-\t+tan(180/pi*\t))+\zz/\Zb*360+\Angledecal}:\Rb/cos(180/pi*\t)})
            % 
            to[bend right=\demiAngle] 
                ({{180/pi*(\AngleT+tan(180/pi*-\AngleT)) +(\zz+1)/\Zb*360-\Angledecal}:
                    \Rb/cos(180/pi*-\AngleT)})
        % 
            plot[domain=-\AngleT:-0,smooth,variable=\t]
                ({{180/pi*(-\t+tan(180/pi*\t)) +(\zz+1)/\Zb*360-\Angledecal}:
                    \Rb/cos(180/pi*\t)})
    } -- cycle;
}

Edit: add missing fill color

0 Answers0