Erstellen einer Rack- und Pignon-Anordnung

Erstellen einer Rack- und Pignon-Anordnung

Ich versuche, eine Anordnung aus Rack und Pignon in zu erstellen tikz. Ich habe einen Code gefunden, mit dem man ein Pignon zeichnen kann. Ich versuche, ein Rack hinzuzufügen, um die Anordnung zu erhalten. Ich habe diesen Code geschrieben

    \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} 

Wie kann ich diesen Code verbessern, um bessere Zahlen zu erhalten? Wie kann ich einige Zitate hinzufügen?

Bildbeschreibung hier eingeben

Antwort1

Eine schmutzige Lösung. Einige Werte müssen manuell angepasst werden.

\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} 

Bildbeschreibung hier eingeben

verwandte Informationen