Creando un arreglo de parrilla y pignon

Creando un arreglo de parrilla y pignon

Estoy intentando crear un arreglo de rejilla y pignon en tikz. Encontré un código que permite dibujar un pignon. Estoy intentando agregar una rejilla para tener el arreglo. escribí este código

    \documentclass[11pt]{scrartcl}
    \usepackage{tikz}

    % #1 number of teeths
    % #2 radius intern
    % #3 radius extern
    % #4 angle from start to end of the first arc
    % #5 angle to decale the second arc from the first 

    \newcommand{\gear}[5]{%
    \foreach \i in {1,...,#1} {%
      [rotate=(\i-1)*360/#1]  (0:#2)  arc (0:#4:#2) {[rounded corners=1.5pt]        
         -- (#4+#5:#3)  arc (#4+#5:360/#1-#5:#3)} --  (360/#1:#2)
    }}  


    \begin{document}
     \begin{tikzpicture}
     \def\a {5}
     \def\b {4}
     \def\c {0.8}
       \draw[line width=0.5mm] \gear{10}{2}{2.9}{10}{8.5};
       \draw [line width=0.5mm, rounded corners=13.5pt] (\c*0-\a,1-\b) -- (\c*1-\a,1-\b) --                 (\c*1-\a,2-\b) -- (\c*2-\a,2-\b) -- (\c*2-\a,1-\b)
       --    (\c*3-\a,1-\b) -- (\c*3-\a,2-\b) -- (\c*4-\a,2-\b) -- (\c*4-\a,1-\b) -- (\c*5-\a,1-\b)
       --    (\c*5-\a,2-\b) -- (\c*6-\a,2-\b) -- (\c*6-\a,1-\b) -- (\c*7-\a,1-\b) -- (\c*7-        \a,2-\b)
       --    (\c*8-\a,2-\b) -- (\c*8-\a,1-\b) -- (\c*9-\a,1-\b) -- (\c*9-\a,2-\b) -- (\c*10-\a,2-\b)
       --    (\c*10-\a,1-\b) --(\c*11-\a,1-\b) -- (\c*11-\a,2-\b) -- (\c*12-\a,2-\b) --         (\c*12-\a,1-\b)
       --    (\c*13-\a,1-\b) -- (\c*13-\a,0-\b) -- (\c*0-\a,0-\b) --cycle;
       ;% -- (2,2) -- (2,1) -- cycle;

     \end{tikzpicture}  
    \end{document} 

¿Cómo puedo mejorar este código para tener una figura mucho mejor? ¿Cómo puedo agregar algunas cotizaciones?

ingrese la descripción de la imagen aquí

Respuesta1

Una solución sucia. Algunos valores se ajustan manualmente.

\documentclass[margin=3mm]{standalone}
    \usepackage{tikz}

    % #1 number of teeths
    % #2 radius intern
    % #3 radius extern
    % #4 angle from start to end of the first arc
    % #5 angle to decale the second arc from the first 

    \newcommand{\gear}[5]{%
    \foreach \i in {1,...,#1} {%
     \draw[line width=0.5mm,xshift=-5mm] [rotate=(\i-1)*360/#1]  (0:#2)  arc (0:#4:#2) {[rounded corners=1.5pt]        
         -- (#4+#5:#3)  arc (#4+#5:360/#1-#5:#3)} --  (360/#1:#2);
    }}  
    
    \newcommand{\pinion}[3]{%
    \foreach \j [count=\i from -#1] in {1,...,#1} {%
  \draw [line width=0.5mm,yshift=-#3cm,rounded corners=1.5pt](\i+\j/2,0)coordinate(\j)--++(0:#2)--++(80:1)--++(0:#2)--++(-80:1)--++(0:#2)coordinate(A);  
    }
    \draw [line width=0.5mm](A)--++(-90:2)coordinate(C)(1)--++(-90:2)coordinate(D);
    \draw [line width=0.5mm](C)--(D);
     }  


    \begin{document}
     \begin{tikzpicture}
       \gear{10}{2}{2.9}{10}{8.5};
       % #1 Number of teeth
       % #2 Width of teeth
       % yshift of rack from 
       \pinion{7}{0.55}{3.1};
    \end{tikzpicture}  
   \end{document} 

ingrese la descripción de la imagen aquí

información relacionada