랙 및 피논 배열 생성

랙 및 피논 배열 생성

에서 랙과 피뇽 배열을 만들려고 합니다 tikz. 피뇽을 그릴 수 있는 코드를 찾았습니다. 정리를 위해 랙을 추가하려고 합니다. 이 코드를 작성했습니다

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

훨씬 더 나은 수치를 얻기 위해 이 코드를 어떻게 개선할 수 있습니까? 코팅을 어떻게 추가할 수 있나요?

여기에 이미지 설명을 입력하세요

답변1

더러운 해결책. 일부 값은 수동으로 조정됩니다.

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

여기에 이미지 설명을 입력하세요

관련 정보