# Involute Spur Gear Geometry


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Executive Summary

**Purpose:** Every diameter, tooth thickness and inspection dimension of
an involute spur gear, external or internal, with profile shift.

**What it does:** `GearGeometry` holds one gear (teeth, module, pressure
angle, profile shift, basic rack, face width) and derives its reference,
base, tip and root diameters, its tooth thickness, the span measurement
over *k* teeth and the measurement over two balls or pins.
`operating_pressure_angle` and `centre_distance` solve a meshing pair,
and `contact_ratio` checks the overlap of the two tooth profiles.

**Units:** gear work is done in millimetres, newtons and MPa throughout
`emachines.gears`, because that is what gear standards and gear drawings
use. Angles are in radians inside the code and in degrees in reports.

**Sign convention (ISO 21771):** an internal gear is entered with a
positive tooth count and `internal=True`. Internally the code gives it a
negative tooth count, so one set of formulas covers both kinds of gear.
A positive profile shift *x* always adds material to the tooth: an
external tooth gets thicker at its base, an internal tooth gets thicker
and its tip moves toward the centre.

## How It Fits Into the Gear Design Workflow

**Upstream:** nothing; this is the base of the `gears` module.

**Downstream:** `gears.layout` (tooth counts, centre distance and
profile shift of a planetary set), `gears.rating` (ISO 6336 strength),
`gears.manufacturing` (gear data sheets and tolerances).

## Notation

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 80%" />
<col style="width: 9%" />
</colgroup>
<thead>
<tr>
<th style="text-align: center;">Symbol</th>
<th style="text-align: left;">Meaning</th>
<th style="text-align: center;">Units</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>z</em></span></td>
<td style="text-align: left;">number of teeth (negative for an internal
gear inside the formulas)</td>
<td style="text-align: center;">–</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>m</em></span></td>
<td style="text-align: left;">module</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>α</em></span></td>
<td style="text-align: left;">reference (tool) pressure angle</td>
<td style="text-align: center;">rad</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>x</em></span></td>
<td style="text-align: left;">profile shift coefficient</td>
<td style="text-align: center;">–</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>h</em><sub><em>a</em><em>P</em></sub><sup>*</sup></span></td>
<td style="text-align: left;">basic rack addendum, per unit module</td>
<td style="text-align: center;">–</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>h</em><sub><em>f</em><em>P</em></sub><sup>*</sup></span></td>
<td style="text-align: left;">basic rack dedendum, per unit module</td>
<td style="text-align: center;">–</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>ρ</em><sub><em>f</em><em>P</em></sub><sup>*</sup></span></td>
<td style="text-align: left;">basic rack root (tool tip) radius, per
unit module</td>
<td style="text-align: center;">–</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>d</em></span></td>
<td style="text-align: left;">reference diameter, <span
class="math inline"><em>d</em> = <em>z</em> <em>m</em></span></td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>d</em><sub><em>b</em></sub></span></td>
<td style="text-align: left;">base diameter, <span
class="math inline"><em>d</em><sub><em>b</em></sub> = <em>d</em>cos <em>α</em></span></td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>d</em><sub><em>a</em></sub></span></td>
<td style="text-align: left;">tip diameter</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>d</em><sub><em>f</em></sub></span></td>
<td style="text-align: left;">root diameter</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>s</em></span></td>
<td style="text-align: left;">tooth thickness on the reference circle
(arc)</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>W</em><sub><em>k</em></sub></span></td>
<td style="text-align: left;">span measurement over <span
class="math inline"><em>k</em></span> teeth (base tangent length)</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>M</em><sub><em>d</em></sub></span></td>
<td style="text-align: left;">dimension over (external) or between
(internal) two balls of diameter <span
class="math inline"><em>D</em><sub><em>M</em></sub></span></td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>α</em><sub><em>w</em></sub></span></td>
<td style="text-align: left;">operating pressure angle of a meshing
pair</td>
<td style="text-align: center;">rad</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>a</em><sub><em>w</em></sub></span></td>
<td style="text-align: left;">operating centre distance</td>
<td style="text-align: center;">mm</td>
</tr>
<tr>
<td style="text-align: center;"><span
class="math inline"><em>ε</em><sub><em>α</em></sub></span></td>
<td style="text-align: left;">transverse contact ratio</td>
<td style="text-align: center;">–</td>
</tr>
</tbody>
</table>

## The Involute Function

inv *α* = tan *α* − *α*.

It is the polar angle of a point on the involute whose pressure angle is
*α*, so tooth thicknesses at different diameters are related through it.
The inverse has no closed form. `inv_inverse` solves inv *α* = *v* by
Newton’s method, using
$\dfrac{d}{d\alpha}\operatorname{inv}\alpha = \tan^2\alpha$:

$$\alpha\_{n+1} = \alpha_n - \frac{\tan\alpha_n - \alpha_n - v}{\tan^2\alpha_n},\qquad \alpha_0 = \min\\\left\[(3v)^{1/3},\\1.4\right\],$$

where the start value comes from the small-angle series
inv *α* ≈ *α*<sup>3</sup>/3. It stops when
|*α*<sub>*n* + 1</sub> − *α*<sub>*n*</sub>| \< 10<sup>−14</sup> rad (a
few iterations).

![](01_involute_files/figure-commonmark/cell-2-output-1.png)

------------------------------------------------------------------------

### inv_inverse

``` python
def inv_inverse(
    value:float, tol:float=1e-14
)->float:
```

*The pressure angle α \[rad\] whose involute is `value` (0 ≤ value \<
~1.5).*

------------------------------------------------------------------------

### inv

``` python
def inv(
    alpha
):
```

*Involute function tan(α) − α (α in radians; works on arrays).*

``` python
for deg in (14.5, 20.0, 25.0, 31.7):
    a = math.radians(deg)
    assert abs(inv_inverse(float(inv(a))) - a) < 1e-12
print(f"inv 20° = {inv(math.radians(20)):.6f}")   # 0.014904
assert abs(inv(math.radians(20)) - 0.0149044) < 1e-6
```

    inv 20° = 0.014904

## Standard Modules

ISO 54 lists preferred modules (series I) and second-choice modules
(series II). Gear cutting tools are stocked in these sizes, so a design
should land on one of them.

------------------------------------------------------------------------

### standard_modules

``` python
def standard_modules(
    m_min:float=0.0, m_max:float=1000000000.0, series_ii:bool=False
)->list[float]:
```

*ISO 54 modules in \[m_min, m_max\], series I only unless `series_ii`.*

``` python
assert standard_modules(0.9, 2.1) == [1.0, 1.25, 1.5, 2.0]
assert 1.75 in standard_modules(1.6, 1.8, series_ii=True)
```

## `GearGeometry`: Theory

A spur gear is fully defined by *z*, *m*, *α*, *x*, the basic rack of
the cutting tool, and the face width *b* (ISO 21771).

**Basic rack.** Every gear here is cut by a tool whose profile is the
ISO 53 basic rack: straight flanks at the pressure angle *α*, equal
tooth and space on the datum line (each *p*/2, with pitch *p* = *π**m*),
addendum *h*<sub>*a**P*</sub><sup>\*</sup>*m*, dedendum
*h*<sub>*f**P*</sub><sup>\*</sup>*m* and root radius
*ρ*<sub>*f**P*</sub><sup>\*</sup>*m*. The module *m* scales the whole
profile.

![](01_involute_files/figure-commonmark/cell-8-output-1.png)

**Tooth count, module, pressure angle and profile shift.** The gear is
generated by rolling its reference circle (*d* = *z* *m*) on the pitch
line of a rack-shaped cutter. With *x* = 0 the cutter datum line is that
pitch line; with profile shift the cutter is moved out by *x* *m*, which
thickens the teeth and raises both the tip and root circles while *d*
and *d*<sub>*b*</sub> stay the same. Negative *x* moves the cutter in.
Small external gears need positive shift to avoid undercut (left panel:
14 teeth, x = 0, the cutter tip has eaten into the bottom of the flank).

![](01_involute_files/figure-commonmark/cell-9-output-1.png)

**Diameters and thicknesses.** The resulting circles and tooth
dimensions on one gear:

![](01_involute_files/figure-commonmark/cell-10-output-1.png)

With the signed tooth count (*z* \< 0 for an internal gear, so *d* \< 0
too):

*d* = *z**m*,   *d*<sub>*b*</sub> = *d*cos *α*,   *p* = *π**m*,   *p*<sub>*b*</sub> = *p*cos *α*

*d*<sub>*a*</sub> = *d* + 2*m* (*h*<sub>*a**P*</sub><sup>\*</sup> + *x* − *k*<sup>\*</sup>),   *d*<sub>*f*</sub> = *d* − 2*m* (*h*<sub>*f**P*</sub><sup>\*</sup> − *x*)

where *k*<sup>\*</sup> is an optional tip reduction (for an internal
gear it is used to keep the ring tips clear of the planet roots and to
lift them off the base circle). For an internal gear the formulas give
negative diameters; their sizes are the diameters you would measure.

Arc tooth thickness on the reference circle, and on any other circle of
diameter *d*<sub>*y*</sub> with pressure angle
*α*<sub>*y*</sub> = arccos (*d*<sub>*b*</sub>/*d*<sub>*y*</sub>):

$$s = m\left(\frac{\pi}{2} + 2x\tan\alpha\right),\qquad s_y = d_y\left(\frac{s}{d} + \operatorname{inv}\alpha - \operatorname{inv}\alpha_y\right).$$

The tip thickness *s*<sub>*a*</sub> (tooth thickness on the tip circle)
must stay above about 0.25 *m* for case-hardened teeth, otherwise the
tip through-hardens and chips.

**Undercut.** A rack-generated external gear is undercut (the cutter
removes the bottom of the working involute) when

$$z \< z\_{min} = \frac{2\\(h\_{aP0}^\* - x - \rho\_{aP0}^\*(1-\sin\alpha))}{\sin^2\alpha},$$

with
*h*<sub>*a**P*0</sub><sup>\*</sup> = *h*<sub>*f**P*</sub><sup>\*</sup>
the cutter addendum and
*ρ*<sub>*a**P*0</sub><sup>\*</sup> = *ρ*<sub>*f**P*</sub><sup>\*</sup>
its tip radius. For the ISO 53 profile A rack (*α* = 20°,
*h*<sub>*f**P*</sub><sup>\*</sup> = 1.25,
*ρ*<sub>*f**P*</sub><sup>\*</sup> = 0.38) this is 17 teeth at *x* = 0.

**In positive sizes**, as `GearGeometry` returns them (the internal-gear
lines are the signed formulas above with *z* \< 0):

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th></th>
<th>External gear</th>
<th>Internal gear</th>
</tr>
</thead>
<tbody>
<tr>
<td>tip diameter</td>
<td><span
class="math inline"><em>d</em><sub><em>a</em></sub> = <em>d</em> + 2<em>m</em> (<em>h</em><sub><em>a</em><em>P</em></sub><sup>*</sup> + <em>x</em> − <em>k</em><sup>*</sup>)</span></td>
<td><span
class="math inline"><em>d</em><sub><em>a</em></sub> = <em>d</em> − 2<em>m</em> (<em>h</em><sub><em>a</em><em>P</em></sub><sup>*</sup> + <em>x</em> − <em>k</em><sup>*</sup>)</span></td>
</tr>
<tr>
<td>root diameter</td>
<td><span
class="math inline"><em>d</em><sub><em>f</em></sub> = <em>d</em> − 2<em>m</em> (<em>h</em><sub><em>f</em><em>P</em></sub><sup>*</sup> − <em>x</em>)</span></td>
<td><span
class="math inline"><em>d</em><sub><em>f</em></sub> = <em>d</em> + 2<em>m</em> (<em>h</em><sub><em>f</em><em>P</em></sub><sup>*</sup> − <em>x</em>)</span></td>
</tr>
<tr>
<td>tooth depth</td>
<td><span
class="math inline"><em>h</em> = |<em>d</em><sub><em>f</em></sub> − <em>d</em><sub><em>a</em></sub>|/2 = <em>m</em> (<em>h</em><sub><em>a</em><em>P</em></sub><sup>*</sup> + <em>h</em><sub><em>f</em><em>P</em></sub><sup>*</sup> − <em>k</em><sup>*</sup>)</span></td>
<td>same</td>
</tr>
<tr>
<td>thickness at <span
class="math inline"><em>d</em><sub><em>y</em></sub></span></td>
<td><span class="math inline">$s_y = d_y\left(\dfrac{s}{d} +
\operatorname{inv}\alpha -
\operatorname{inv}\alpha_y\right)$</span></td>
<td><span class="math inline">$s_y = d_y\left(\dfrac{s}{d} -
\operatorname{inv}\alpha +
\operatorname{inv}\alpha_y\right)$</span></td>
</tr>
<tr>
<td>tip thickness</td>
<td><span
class="math inline"><em>s</em><sub><em>a</em></sub> = <em>s</em><sub><em>y</em></sub></span>
at <span
class="math inline"><em>d</em><sub><em>y</em></sub> = max (<em>d</em><sub><em>a</em></sub>, <em>d</em><sub><em>b</em></sub>)</span></td>
<td>same</td>
</tr>
</tbody>
</table>

The internal tooth gets wider towards its root (larger diameter), which
is why the sign of the involute terms flips.

**Root form diameter *d*<sub>*F**f*</sub>** (where the generated
involute ends and the fillet begins). The straight part of the cutter
flank reaches

*h*<sub>*l**i**n*</sub> = *m*\[*h*<sub>*f**P*</sub><sup>\*</sup> − *ρ*<sub>*f**P*</sub><sup>\*</sup>(1 − sin *α*) − *x*\]

below the pitch line. The last involute point it generates lies on the
line of action at a distance *g* from the base-circle tangent point,

$$g = \frac{d\sin\alpha}{2} - \frac{h\_{lin}}{\sin\alpha}\\\text{(external)},\qquad g = \frac{d\sin\alpha}{2} + \frac{h\_{lin}}{\sin\alpha}\\\text{(internal)},\qquad d\_{Ff} = 2\sqrt{r_b^2 + g^2}.$$

If *g* \< 0 on an external gear the involute would have to start inside
the base circle: the tooth is undercut and
*d*<sub>*F**f*</sub> = *d*<sub>*b*</sub>. The internal value assumes a
rack-type cutter; a pinion-type shaper gives a slightly different
fillet, so confirm it with the cutter data.

------------------------------------------------------------------------

### GearGeometry

``` python
def GearGeometry(
    z:int, m:float, x:float=0.0, b:float=10.0, alpha:float=0.3490658503988659, internal:bool=False, ha:float=1.0,
    hf:float=1.25, rho_f:float=0.38, k_tip:float=0.0, name:str='gear'
)->None:
```

*One involute spur gear (ISO 21771). Lengths in mm, angles in radians.*

## Attributes

z : int Number of teeth, always entered positive m : float Module \[mm\]
x : float Profile shift coefficient (positive adds material to the
tooth, ISO 21771) b : float Face width \[mm\] alpha : float Reference
pressure angle \[rad\] (default 20°) internal : bool True for an
internal (ring) gear ha : float Basic rack addendum coefficient h_aP\*
(default 1.0) hf : float Basic rack dedendum coefficient h_fP\* (default
1.25) rho_f : float Basic rack root radius coefficient ρ_fP\* (default
0.38, ISO 53 profile A) k_tip : float Tip reduction coefficient k\*
(default 0) name : str Label used in reports

### Example

A 17-tooth, module 1.5 sun with a +0.3 shift and the 67-tooth ring of
the same planetary set.

``` python
sun = GearGeometry(z=17, m=1.5, x=0.3, b=20, name="sun")
ring = GearGeometry(z=67, m=1.5, x=0.0, b=20, internal=True, name="ring")
for g in (sun, ring):
    print(f"{g.name:5s} d = {g.d:7.3f}  db = {g.db:7.3f}  da = {g.da:7.3f}  df = {g.df:7.3f}  "
          f"s = {g.s:.4f}  sa = {g.sa:.3f}  d_Ff = {g.d_form:.3f} mm")
assert math.isclose(sun.da, 25.5 + 2 * 1.5 * 1.3) and math.isclose(sun.df, 25.5 - 2 * 1.5 * 0.95)
assert math.isclose(ring.da, 100.5 - 3.0) and math.isclose(ring.df, 100.5 + 3.75)
assert not sun.undercut and GearGeometry(z=12, m=1).undercut
assert abs(GearGeometry(z=17, m=1).z_min_undercut - 17.1) < 0.2     # ISO profile A, x = 0
```

    sun   d =  25.500  db =  23.962  da =  29.400  df =  22.650  s = 2.6838  sa = 0.801  d_Ff = 24.101 mm
    ring  d = 100.500  db =  94.439  da =  97.500  df = 104.250  s = 2.3562  sa = 1.361  d_Ff = 103.828 mm

## Inspection Dimensions: Theory

Tooth thickness cannot be measured directly, so gear drawings specify it
through a dimension the gear shop can measure: the span over *k* teeth
or the dimension over two balls (or pins). Both are linked exactly to
the reference tooth thickness *s*.

![](01_involute_files/figure-commonmark/cell-13-output-1.png)

**Span measurement (external gears).** A disc micrometer touching two
flanks *k* teeth apart lies along a base tangent, so

$$W_k = (k-1)\\p_b + s_b,\qquad s_b = d_b\left(\frac{s}{d} + \operatorname{inv}\alpha\right).$$

*k* is chosen so that the anvils touch near the middle of the tooth
depth:

$$k = \operatorname{round}\left\[\frac{z}{\pi}\left(\tan\alpha_x - \frac{2x\tan\alpha}{z} - \operatorname{inv}\alpha\right) + 0.5\right\],\qquad \cos\alpha_x = \frac{d_b}{d + 2xm}.$$

**Dimension over balls (external) or between balls (internal).** A ball
of diameter *D*<sub>*M*</sub> in a tooth space has its centre at
pressure angle *α*<sub>*M*</sub> with (signed *z*, *d*,
*d*<sub>*b*</sub>)

$$\operatorname{inv}\alpha_M = \frac{s}{d} + \operatorname{inv}\alpha + \frac{D_M}{d_b} - \frac{\pi}{z}$$

and the measurement across two balls is

$$M_d = \frac{d_b}{\cos\alpha_M} + D_M\\\\(z \text{ even}),\qquad M_d = \frac{d_b\cos(\pi/2z)}{\cos\alpha_M} + D_M\\\\(z \text{ odd}).$$

For an internal gear the same formulas with negative *z*, *d*,
*d*<sub>*b*</sub> give
*M*<sub>*d*</sub> = *d*<sub>*b*</sub>/cos *α*<sub>*M*</sub> − *D*<sub>*M*</sub>
in positive sizes. The ball touches the flank where
tan *α*<sub>*c*</sub> = tan *α*<sub>*M*</sub> − *D*<sub>*M*</sub>/*d*<sub>*b*</sub>.
`ball_diameter` picks the ball that touches on the reference circle:
with *η* = *π*/|*z*|−*s*/*d* the half-angle of the tooth space,

*D*<sub>*M*</sub> = *d*<sub>*b*</sub> \[tan (*α* + *η*) − tan *α*\] (external),   *D*<sub>*M*</sub> = *d*<sub>*b*</sub> \[tan *α* − tan (*α* − *η*)\] (internal),

rounded to 0.01 mm, a step that measuring-pin sets come in. If the balls
would then sit below the tips (common with a positive shift, which
raises the tip of an external gear, and on internal gears), the ball is
enlarged until it stands out past the tips by 0.2 *m*, so the micrometer
touches the balls and not the teeth.

In equations, *D*<sub>*M*</sub> is increased in 0.01 mm steps until

*M*<sub>*d*</sub> − *d*<sub>*a*</sub> ≥ 0.2 *m* (external),   *d*<sub>*a*</sub> − *M*<sub>*d*</sub> ≥ 0.2 *m* (internal),

and the diameter at which the ball then touches the flank, reported so
you can check it lies on the working involute
(*d*<sub>*F**f*</sub> ≤ *d*<sub>*c*</sub> ≤ *d*<sub>*a*</sub>), is

$$d_c = \frac{d_b}{\cos\alpha_c},\qquad \tan\alpha_c = \tan\alpha_M - \frac{D_M}{d_b}.$$

The span tooth count is limited to 2 ≤ *k* ≤ *z* − 1. All three
functions accept a tooth thickness *s* other than the nominal one, so
the same formulas give the upper and lower inspection limits once the
thickness allowances are applied (*s* + *A*<sub>*s**n**e*</sub>,
*s* + *A*<sub>*s**n**i*</sub> in `gears.manufacturing`).

------------------------------------------------------------------------

### ball_measurement

``` python
def ball_measurement(
    g:GearGeometry, D:float | None=None, s:float | None=None
)->tuple[float, float]:
```

*Dimension over two balls (external) or between two balls (internal)
\[mm\].*

Returns (M_d, d_contact): the measurement and the diameter where the
ball touches the flank.

------------------------------------------------------------------------

### ball_diameter

``` python
def ball_diameter(
    g:GearGeometry, protrude:float=0.2
)->float:
```

*Ball or pin diameter \[mm\], rounded to 0.01 mm: touches the flanks
near the reference circle,* enlarged if needed so the balls stand out
past the tips by at least `protrude`·m (otherwise a micrometer anvil
would rest on the tips instead of the balls).

------------------------------------------------------------------------

### span_measurement

``` python
def span_measurement(
    g:GearGeometry, s:float | None=None, k:int | None=None
)->float:
```

*Base tangent length W_k \[mm\] over k teeth for reference tooth
thickness s (default nominal).*

------------------------------------------------------------------------

### span_teeth

``` python
def span_teeth(
    g:GearGeometry
)->int:
```

*Number of teeth k to span for the base tangent length of an external
gear.*

``` python
# Check against the span tables: z = 30, x = 0 → k = 4, W* = 10.7526 per unit module
g30 = GearGeometry(z=30, m=2)
assert span_teeth(g30) == 4 and abs(span_measurement(g30) / 2 - 10.7526) < 1e-4
# Ball touching at the reference circle
for g in (sun, ring, g30, GearGeometry(z=25, m=1, x=-0.2)):
    D = ball_diameter(g)
    M, dc = ball_measurement(g, D)
    print(f"{g.name:5s} z={g.z:3d}  D_M = {D:.2f}  M_d = {M:.4f}  tip d_a = {g.da:.3f}  contact at d = {dc:.3f} (ref {g.d:.3f})")
    assert (g.da - M if g.internal else M - g.da) >= 0.2 * g.m - 1e-9
    assert min(g.da, g.d_form) - 1e-9 <= dc <= max(g.da, g.d_form) + 1e-9      # contact on the working flank
```

    sun   z= 17  D_M = 2.62  M_d = 29.7276  tip d_a = 29.400  contact at d = 26.082 (ref 25.500)
    ring  z= 67  D_M = 2.49  M_d = 97.1490  tip d_a = 97.500  contact at d = 100.490 (ref 100.500)
    gear  z= 30  D_M = 3.41  M_d = 64.6573  tip d_a = 64.000  contact at d = 59.997 (ref 60.000)
    gear  z= 25  D_M = 1.88  M_d = 27.5405  tip d_a = 26.600  contact at d = 25.006 (ref 25.000)

A thinner tooth (the tolerance allowances of `gears.manufacturing`) must
give a smaller span and a smaller dimension over balls on an external
gear, and a *larger* dimension between balls on an internal gear:

``` python
ds = -0.05
assert span_measurement(sun, sun.s + ds) < span_measurement(sun)
assert ball_measurement(sun, 2.8, sun.s + ds)[0] < ball_measurement(sun, 2.8)[0]
assert ball_measurement(ring, 2.5, ring.s + ds)[0] > ball_measurement(ring, 2.5)[0]
# span change = Δs·cos α exactly
assert math.isclose(span_measurement(sun) - span_measurement(sun, sun.s + ds), -ds * math.cos(sun.alpha))
```

## Meshing Pair: Theory

Two gears mesh along the **line of action**, the common tangent of their
base circles (*T*<sub>1</sub>*T*<sub>2</sub>). Contact starts where the
driven gear’s tip circle cuts it (A) and ends where the driver’s tip
circle does (E); AE is the path of contact. The line of action is
inclined at the operating pressure angle *α*<sub>*w*</sub> to the
tangent at the pitch point C, and the axes are *a*<sub>*w*</sub> apart.

![](01_involute_files/figure-commonmark/cell-20-output-1.png)

Two gears with profile shifts *x*<sub>1</sub>, *x*<sub>2</sub> mesh
without backlash at the operating pressure angle (signed *z* for an
internal gear)

$$\operatorname{inv}\alpha_w = \operatorname{inv}\alpha + 2\tan\alpha\\\frac{x_1 + x_2}{z_1 + z_2}$$

and the operating centre distance is

$$a_w = \frac{(z_1 + z_2)\\m}{2}\\\frac{\cos\alpha}{\cos\alpha_w}.$$

Turned around, a required centre distance fixes the shift sum:
cos *α*<sub>*w*</sub> = *a*cos *α*/*a*<sub>*w*</sub> with
*a* = (*z*<sub>1</sub> + *z*<sub>2</sub>)*m*/2, then
*x*<sub>1</sub> + *x*<sub>2</sub> = (*z*<sub>1</sub> + *z*<sub>2</sub>)(inv *α*<sub>*w*</sub> − inv *α*)/(2tan *α*).
This is how the planet–ring shift is found once the sun–planet mesh has
fixed *a*<sub>*w*</sub>.

**Transverse contact ratio** (gear 1 external, gear 2 external or
internal):

$$\varepsilon\_\alpha = \frac{\sqrt{r\_{a1}^2 - r\_{b1}^2} \pm \sqrt{r\_{a2}^2 - r\_{b2}^2} \mp a_w\sin\alpha_w}{p_b},$$

upper signs for an external pair, lower signs for an internal pair. Keep
*ε*<sub>*α*</sub> ≥ 1.2; values from 1.4 to 1.8 are usual for spur
gears.

**Start of active profile and interference.** Measure lengths along the
line of action.
*T*<sub>1</sub>*T*<sub>2</sub> = *a*<sub>*w*</sub>sin *α*<sub>*w*</sub>
is the distance between the two tangent points, and
$t_i = \sqrt{r\_{ai}^2 - r\_{bi}^2}$ is the distance from
*T*<sub>*i*</sub> to where the tip circle of gear *i* crosses the line.
Contact on gear 1 starts where the tip of gear 2 reaches it, at a
distance *g*<sub>1</sub> from *T*<sub>1</sub>, and likewise for gear 2:

<table>
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr>
<th></th>
<th>External pair</th>
<th>Internal pair (gear 2 = ring)</th>
</tr>
</thead>
<tbody>
<tr>
<td>on gear 1</td>
<td><span
class="math inline"><em>g</em><sub>1</sub> = <em>T</em><sub>1</sub><em>T</em><sub>2</sub> − <em>t</em><sub>2</sub></span></td>
<td><span
class="math inline"><em>g</em><sub>1</sub> = <em>t</em><sub>2</sub> − <em>T</em><sub>1</sub><em>T</em><sub>2</sub></span></td>
</tr>
<tr>
<td>on gear 2</td>
<td><span
class="math inline"><em>g</em><sub>2</sub> = <em>T</em><sub>1</sub><em>T</em><sub>2</sub> − <em>t</em><sub>1</sub></span></td>
<td><span
class="math inline"><em>g</em><sub>2</sub> = <em>T</em><sub>1</sub><em>T</em><sub>2</sub> + <em>t</em><sub>1</sub></span>
(outermost contact on the ring)</td>
</tr>
</tbody>
</table>

$$d\_{Nf\\i} = 2\sqrt{r\_{bi}^2 + g_i^2}.$$

The mesh has **interference** if *g*<sub>1</sub> \< 0 (and, for an
external pair, *g*<sub>2</sub> \< 0): the mating tip would have to reach
past the tangent point. It also has interference if contact runs into a
fillet, that is *d*<sub>*N**f*1</sub> \< *d*<sub>*F**f*1</sub> on gear
1, and on gear 2 *d*<sub>*N**f*2</sub> \< *d*<sub>*F**f*2</sub>
(external) or *d*<sub>*N**f*2</sub> \> *d*<sub>*F**f*2</sub> (internal,
where the fillet is outside the working flank). For the ring,
*g*<sub>1</sub> ≥ 0 is the condition that its tip lies beyond
*T*<sub>1</sub>; if not, the ring tip digs into the planet root.

**Tip clearance** is the radial gap between each tip circle and the
mating root circle:

*c*<sub>12</sub> = *a*<sub>*w*</sub> − *r*<sub>*a*1</sub> − *r*<sub>*f*2</sub>,  *c*<sub>21</sub> = *a*<sub>*w*</sub> − *r*<sub>*a*2</sub> − *r*<sub>*f*1</sub> (external);   *c*<sub>12</sub> = *r*<sub>*f*2</sub> − *a*<sub>*w*</sub> − *r*<sub>*a*1</sub>,  *c*<sub>21</sub> = *r*<sub>*a*2</sub> − *a*<sub>*w*</sub> − *r*<sub>*f*1</sub> (internal).

It is 0.25 *m* with the standard rack and no shift; aim for at least
0.1 *m*, since below that oil is trapped and the tip may touch the
fillet.

**Pass criteria used by `MeshCheck.ok`:** *ε*<sub>*α*</sub> ≥ 1.2, no
interference, and both clearances above zero. Both gears of a pair must
have the same module and pressure angle.

------------------------------------------------------------------------

### mesh_check

``` python
def mesh_check(
    g1:GearGeometry, g2:GearGeometry
)->MeshCheck:
```

*Contact ratio, active profile, interference and tip clearance of a
mesh.*

------------------------------------------------------------------------

### MeshCheck

``` python
def MeshCheck(
    alpha_w:float, a_w:float, eps_alpha:float, d_Nf1:float, d_Nf2:float, d_Ff1:float, d_Ff2:float, clearance12:float,
    clearance21:float, interference:bool
)->None:
```

*Geometry checks of one mesh. Lengths in mm.*

alpha_w : operating pressure angle \[rad\] a_w : operating centre
distance eps_alpha : transverse contact ratio d_Nf1, d_Nf2 : start of
active profile on each gear (g2: for an internal gear, the outermost
contact diameter) d_Ff1, d_Ff2 : root form diameters clearance12 : g1
tip to g2 root clearance21 : g2 tip to g1 root interference : True if
contact runs into a fillet or (internal) the ring tip lies inside T1

------------------------------------------------------------------------

### contact_ratio

``` python
def contact_ratio(
    g1:GearGeometry, g2:GearGeometry
)->float:
```

*Transverse contact ratio ε_α of the pair (g1 external, g2 external or
internal).*

------------------------------------------------------------------------

### shift_sum_for_centre_distance

``` python
def shift_sum_for_centre_distance(
    z1:int, z2_signed:int, m:float, a_w:float, alpha:float=0.3490658503988659
)->float:
```

*Profile shift sum x1 + x2 that gives centre distance a_w \[mm\] (z2
negative for an internal gear).*

------------------------------------------------------------------------

### centre_distance

``` python
def centre_distance(
    g1:GearGeometry, g2:GearGeometry
)->float:
```

*Operating centre distance a_w \[mm\] of a backlash-free mesh.*

------------------------------------------------------------------------

### operating_pressure_angle

``` python
def operating_pressure_angle(
    g1:GearGeometry, g2:GearGeometry
)->float:
```

*Operating pressure angle α_w \[rad\] of a backlash-free mesh (g2 may be
internal).*

### Example

The sun above with a 25-tooth planet at *x* = −0.3 (a zero-sum pair, so
*a*<sub>*w*</sub> = *a*), and the ring meshing with the planet at the
same centre distance. The ring then needs *x* = +0.3, and its lengthened
teeth reach into the planet fillet; shortening them by 0.2 *m* (`k_tip`)
clears it at the cost of some contact ratio.

``` python
planet = GearGeometry(z=25, m=1.5, x=-0.3, b=20, name="planet")
sp = mesh_check(sun, planet)
xr = shift_sum_for_centre_distance(planet.z, -ring.z, 1.5, sp.a_w) - planet.x
pr0 = mesh_check(planet, ring.with_(x=xr))
print(f"ring at x = {xr:+.2f}, no tip reduction: interference = {pr0.interference} "
      f"(contact starts at d = {pr0.d_Nf1:.3f} on the planet, its form circle is {pr0.d_Ff1:.3f})")
ring2 = ring.with_(x=xr, k_tip=0.2)      # shorten the ring teeth by 0.2 m
pr = mesh_check(planet, ring2)
print(f"sun–planet:  a_w = {sp.a_w:.4f}  α_w = {math.degrees(sp.alpha_w):.3f}°  ε_α = {sp.eps_alpha:.3f}  "
      f"clearances {sp.clearance12:.3f}/{sp.clearance21:.3f} mm  ok={sp.ok}")
print(f"planet–ring: a_w = {pr.a_w:.4f}  α_w = {math.degrees(pr.alpha_w):.3f}°  ε_α = {pr.eps_alpha:.3f}  "
      f"clearances {pr.clearance12:.3f}/{pr.clearance21:.3f} mm  x_ring = {xr:+.3f}  ok={pr.ok}")
assert math.isclose(sp.a_w, (17 + 25) * 1.5 / 2) and math.isclose(pr.a_w, sp.a_w)
assert math.isclose(xr, 0.3) and pr0.interference and sp.ok and pr.ok
```

    ring at x = +0.30, no tip reduction: interference = True (contact starts at d = 35.260 on the planet, its form circle is 35.267)
    sun–planet:  a_w = 31.5000  α_w = 20.000°  ε_α = 1.530  clearances 0.375/0.375 mm  ok=True
    planet–ring: a_w = 31.5000  α_w = 20.000°  ε_α = 1.876  clearances 0.375/0.675 mm  x_ring = +0.300  ok=True

------------------------------------------------------------------------

## Tests

## References

- ISO 21771:2007 — *Gears — Cylindrical involute gears and gear pairs —
  Concepts and geometry*. Signed tooth counts for internal gears,
  profile shift, operating pressure angle.
- ISO 53:1998 — *Standard basic rack tooth profile* (profile A: α = 20°,
  h_aP = 1.0 m, h_fP = 1.25 m, ρ_fP = 0.38 m).
- ISO 54:1996 — *Modules*.
- DIN 3960:1987 — *Definitions, parameters and equations for involute
  cylindrical gears*: span and over-ball measurements.
- Linke, H. (2010). *Stirnradverzahnung* (2nd ed.). Hanser —
  interference checks for internal gear pairs.
