Creating gears in TikZ
You need to adapt the only line to draw the picture. The rotation here is 360/10. It's possible to modify the length of arcs, the type of teeth.
\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick]
\foreach \i in {1,2,...,10} {%
[rotate=(\i-1)*36]
(0:2) arc (0:18:2) {[rounded corners=2pt] -- ++(18: 0.3) arc (18:36:2.3) } -- ++(36: -0.3)
};
\end{tikzpicture}
\end{document}
update
How to modify :
number of teeths : n
radius intern circle r1
radius extern circle r2
rotation = 360/n
first arc start angle =0 end angle=
arc(0:a:r1)
second arc start angle =a+b end angle=<360/n-b>
arc(a+b:360/n-b:r2)
line between arcs
-- (a+b:r2)
last line
-- (360/n:r1)
\begin{tikzpicture} \draw[thick] \foreach \i in {1,2,...,10} {% [rotate=(\i-1)*36] (0:2) arc (0:12:2) -- (18:2.4) arc (18:30:2.4) -- (36:2) }; \end{tikzpicture}
With a macro
\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}
\draw[thick] \gear{18}{2}{2.4}{10}{2};
\end{tikzpicture}
\end{document}
With a adjusted macro
...you can also use \draw[fill]
\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
% #6 inner radius to cut off
\newcommand{\gear}[6]{%
(0:#2)
\foreach \i [evaluate=\i as \n using {\i-1)*360/#1}] in {1,...,#1}{%
arc (\n:\n+#4:#2) {[rounded corners=1.5pt] -- (\n+#4+#5:#3)
arc (\n+#4+#5:\n+360/#1-#5:#3)} -- (\n+360/#1:#2)
}%
(0,0) circle[radius=#6]
}
\begin{document}
\begin{tikzpicture}
\fill[even odd rule] \gear{18}{2}{2.4}{10}{2}{1};
\end{tikzpicture}
\end{document}
voici une solution plus conforme à la représentation d'une roue dentée avec developpante de cercle il sufit de préciser le nombre de dents, le module, l'angle de pression pour obtenir le tracé j'ai malgré tout simplifié le tracé pour les cercles de tetes et de pied
here is a solution more in line with the representation of a gear with involute sufit it specify the number of teeth, module, pressure angle to get the lay I still simplified the plot for circle heads and feet
Attention: le script ci-dessous ne fonctionne qu'avec PGF 2.1, version pgf 3 à la suite
Warning : this first script run only with pgf2.1
\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\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[dashed] (0,0) circle (\Rpr);
% \draw[red,dashed] (0,0) circle (\Rb);
% \draw[dashed] (0,0) circle (\Rt);
% \draw[dashed] (0,0) circle (\Rp);
\foreach \zz in{1,2,...,\Zb}{
\coordinate(e\zz) at (\zz/\Zb*360+\Angledecal:\Rb);
\draw[domain=-0:\AngleT,smooth,variable=\t,thick]
plot ({{180/pi*(-\t+tan(180/pi*\t)) +\zz/\Zb*360+\Angledecal}:\Rb/cos(180/pi*\t)})coordinate(d\zz);
\coordinate(g\zz) at ({(\zz))/\Zb*360-\Angledecal}:\Rb);
\draw[domain=-0:-\AngleT,smooth,variable=\t,thick]
plot ({{180/pi*(-\t+tan(180/pi*\t)) +(\zz+1)/\Zb*360-\Angledecal}:\Rb/cos(180/pi*\t)})coordinate(f\zz);
\draw[blue] (d\zz) to[bend right=\demiAngle] (f\zz);
\draw[rounded corners=\modu](e\zz) -- (\zz/\Zb*360+\Angledecal:\Rp) to[bend left=\demiAngle] (\zz/\Zb*360-\Angledecal:\Rp) -- (g\zz);
}
}
\begin{document}
\begin{tikzpicture}[scale=0.2]
\gear{3}{15}{20}
\begin{scope}[xshift=40.5cm,rotate=180/12]
\gear{3}{12}{20}
\end{scope}
\end{tikzpicture}
\end{document}
Script pour/for PGF3
\newcommand{\gear}[4][]{%
\def\modu{#2}
\def\Zb{#3}
\def\AngleA{#4}
\pgfmathsetmacro{\Rpr}{\Zb*\modu/2}
\pgfmathsetmacro{\Rb}{\Rpr*cos(\AngleA)}
\pgfmathsetmacro{\Rt}{\Rpr+\modu}
\pgfmathsetmacro{\Rp}{\Rpr-1.25*\modu}
\pgfmathsetmacro{\AngleT}{sqrt(\Rt^2/\Rb^2-1)}
%\pgfmathsetmacro{\AnglePr}{pi/180*acos(\Rb/\Rpr)}
\pgfmathsetmacro{\AnglePr}{180/pi*sqrt(\Rpr^2/\Rb^2-1)}
\pgfmathsetmacro{\demiAngle}{180/\Zb}
\pgfmathsetmacro{\Angledecal}{(\demiAngle+0.075*\AnglePr)/2}%
\def\xxt{\Rb*(cos(\t r)+\t*sin(\t r))}
\def\yyt{\Rb*(sin(\t r) - \t*cos(\t r))}
\foreach \zz in{1,2,...,\Zb}{
\coordinate(e\zz) at (\zz/\Zb*360+\Angledecal:\Rb);
\draw[fill](e\zz)circle(0.1);
\draw[domain=-0:\AngleT,smooth,variable=\t,thick,green,#1]
plot ({atan2(\xxt,\yyt)-90+\zz/\Zb*360+\Angledecal}:{\Rb*sqrt(1+\t^2)} )coordinate(f\zz);
\coordinate(g\zz) at ({(\zz+1))/\Zb*360-\Angledecal}:\Rb);
\draw[domain=-0:\AngleT,smooth,variable=\t,thick,green,#1]
plot ({atan2(\xxt,-\yyt)-90+(\zz)/\Zb*360-\Angledecal}:{\Rb*sqrt(1+\t^2)} )coordinate(d\zz);
\draw[#1] (f\zz) to[bend left=\demiAngle] (d\zz);
\draw[rounded corners=\modu,#1](e\zz) -- (\zz/\Zb*360+\Angledecal:\Rp) to[bend right=\demiAngle] ({(\zz+1)/\Zb*360-\Angledecal}:\Rp) -- (g\zz);
}
}
\begin{tikzpicture}[scale=0.15]
\gear[red,ultra thick]{2}{15}{20}
\draw[red,ultra thick] (0,0) coordinate(O1)node[below left]{$O_1$}circle (1);
\draw[thin,red,dashed](O1) circle (15);
\begin{scope}[xshift=27cm,rotate=180/12]
\gear[blue,ultra thick]{2}{12}{20}
\draw[blue,ultra thick] (0,0)coordinate(O2)node[below left]{$O_2$} circle (1);
\draw[thin,blue,dashed](O2) circle (12);
\end{scope}
\draw[thin,black,dashed] (O1) --++(-18,0) --(15,0) coordinate(I) node[below right]{$I$}-- (O2) --++(18,0);
\draw[thin,black,dashed] (O1)--+(0,18)--+(0,-18);
\draw[thin,black,dashed] (O2)--+(0,18)--+(0,-18);
\draw[thin,black] (I) -- +(70:15)--+(-110:15);
\draw[thin,black] (I) --+(70:12)coordinate(aa)-- +(-70:15)--+(110:15);
\draw[thin,black] (I) -- +(-90:15)--+(90:12)coordinate(bb)--+(90:15);
\draw[-latex] (bb) to [bend left=10] node[above]{$\alpha$} (aa);
\draw (d1) -- ++(1,1);
\end{tikzpicture}
It's probably easiest to use \foreach
to repeat an exactly calculated path for each tooth. Maybe something like the following (though I don't know how exactly gears have to be shaped to work correctly).
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\teeth{10}
\def\innerRadius{1cm}
\def\outerRadius{1.3cm}
\pgfmathsetmacro\angle{360/(2*\teeth)}
\foreach \i in {1,2,...,\teeth} {
\draw ({\i*\angle*2}:\innerRadius)
-- ({(2*\i+0.5)*\angle}:\outerRadius)
arc [radius=\outerRadius, start angle={(2*\i+0.5)*\angle}, end angle={(2*\i+.9)*\angle}]
-- ({(2*\i+1.4)*\angle}:\innerRadius)
arc [radius=\innerRadius, start angle={(2*\i+1.4)*\angle}, end angle={(2*\i+2)*\angle}];
}
\end{tikzpicture}
\end{document}