gear - Generation of gears, racks, etc

This module provide functions to generate racks and gears with many different shapes.

The mainstream gears are involute gears (using involute of circles as contact curves). This is due to the standard shape of racks. And involute gears are the best choice for most designs, which is why the current implementation focusses on them.

However the tools here are modular, which means you can combine them with your own functions to create customized gears.

Examples

As a first use, you may want to generate a fully finished spur gear If you do not specify optional arguments, the function will provide good defaults for it.

>>> # fully featured gear
>>> gear(step=3, z=12, depth=4, bore_radius=1.5)

You may want to generate a more bizarre gear, with a a different hub for instance. You will then need to assemble a gear from its 3 components: exterior (tooths), structure (between hub and exterior), and hub (what holds the gear on an axis)

>>> # this assemble a gear specifying each independant sub-parts
>>> ext_radius = (3 * 12) / (2 * pi) - 3
>>> int_radius = 4
>>> geargather(
...      gearexterior(repeat_circular(gearprofile(3, 30), 30), depth=4),
...      gearstructure("rounded", ext_radius, int_radius, 2, patterns=6),
...      my_hub_mesh,
... )

For reuse in your custom functions, the functions used to generate the gears are exposed:

>>> # this is the raw profile of a tooth
>>> gearprofile(step=3, z=12)

Tooth profiles generation

The following functions are focussing on involute gears. If you want more details on how involutes gears are defined and computed, you can take a look at the algorithm section

rackprofile(step, h=None, offset=0, alpha=0.3490658503988659, resolution=None) Wire[source]

Generate a 1-period tooth profile for a rack

Parameters:
  • step – period length over the primitive line
  • h – tooth half height
  • offset – rack reference line offset with the primitive line (as a distance) - the primitive line is the adherence line with gears - the reference line is the line half the tooth is above and half below
  • alpha – angle of the tooth sides, a.k.a pressure angle of the contact

example:

>>> rackprofile(1)
../_images/rackprofile.png
gearprofile(step, z, h=None, offset=0, alpha=0.3490658503988659, resolution=None, **kwargs) Wire[source]

Generate a 1-period tooth profile for a straight gear

Parameters:
  • step – period length over the primitive circle
  • z – number of tooth on the gear this profile is meant for
  • h – tooth half height
  • offset – offset distance of the matching rack profile (see above)
  • alpha – pressure angle in the contact

example:

>>> gearprofile(1, 12)
../_images/gearprofile.png
spherical_rackprofile(z: float, pressure_angle: float = 0.3490658503988659, ka: float = 1, kd: float = 1.25, resolution=None)[source]

Return a Wire which is a tooth of the rack.

Parameters:
  • z (float) – number of tooth of the rack equal to z_pinion / sin(pitch_cone_angle) or z_wheel / sin(shaft_angle - pitch_cone_angle)
  • pressure_angle (float) – the pressure angle of the gear
  • ka (float) – the addendum coefficient
  • kd (float) – the dedendum coefficient

example:

>>> spherical_rackprofile(12)
../_images/spherical_rackprofile.png
spherical_gearprofile(z: int, pitch_cone_angle: float, pressure_angle: float = 0.3490658503988659, ka: float = 1, kd: float = 1.25, resolution=None) Wire[source]

Generate and return a Wire of a 1-period tooth spherical profile for a bevel gear

Parameters:
  • z (int) – number of tooth on the gear this profile is meant for
  • pitch_cone_angle (float) – the pitch cone angle
  • pressure_angle (float) – pressure angle of the tooth
  • ka (float) – addendum coefficient
  • kd (float) – dedendum coefficient

example:

>>> spherical_gearprofile(12, pi/4)
../_images/spherical_gearprofile.png

Gear generation

gear(step, z: int, depth, bore_radius=0, int_height=0, pattern='full', **kwargs) Mesh[source]

Generate a pinion.

Any extra argument will go to functions gearprofile, gearstructure, or gearhub

Parameters:
  • step (float) – tooth step over the primitive curve, same as the matching rack step the primitive perimeter is step * z and radius is step * z / 2*pi
  • z (int) – number of teeth
  • depth (float) – extrusion eight - width of the gear along its axis
  • bore_radius (float) – radius of the main bore
  • int_height (float) – if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height
  • pattern – determine the structure between exterior (tooth) and hub This argument specifies the use a a function named 'pattern_'+pattern in this module.
  • Extra parameters for gearprofile

    offset (float): offset of tooth (as a distance) alpha (float): pressure angle in radian

  • Extra parameters for gearexterior

    helix_angle (float): helix angle to get a helical pinion in radian chamfer (bool | float | (float, float)):

    set the parameter of chamfer (angle, ratio) such as angle is the chamfer angle, ratio is where the chamfer is applied (rmin + ratio * (rmax - rmin))

  • Extra parameters for gearstructure

    ratio (float): influence the proportion of dimensions of the structure

    Note: int_height impacts the thickness of the structure unless specified

  • Extra parameters for gearhub

    hub_height (float): height of the hub shoulder

Note

  • int_height impacts the height of the hub unless specified.
  • if hub_height is null, there will be no hub.

a simple use:

>>> gear(3, 12, 4, bore_radius=1.5)
../_images/gear-minimal.png

a more advanced use:

>>> gear(3, 30, 4, bore_radius=2, pattern='rounded', patterns=6, int_height=1, chamfer=radians(20))
../_images/gear-advanced.png
geargather(exterior, structure, hub) Mesh[source]

Gather all parts: exterior, structure, and hub

You can obtain them via the provided functions, or generate them yourself.

gearexterior(profile: Wire, z, depth, step=None, helix_angle=0, chamfer=0, resolution=None, **kwargs) Mesh[source]

Generate the external part of the pinion

Parameters:
  • profile (Web) – profile of the pinion generated by gearprofile
  • depth (float) – extrusion eight - width of the gear along its axis
  • step (float) – step of chordal pitch, must be specified for non-null helix_angle, unused otherwise
  • helix_angle (float) – helix angle for helical gears - only without bevel; bevel = False - it must be a radian angle
  • chamfer (bool | float | (float, float)) – set the parameter of chamfer (angle, ratio) such as angle is the chamfer angle, ratio is where the chamfer is applied (rmin + ratio * (rmax - rmin))
../_images/gearexterior.png
gearstructure(pattern, ext_radius, int_radius, depth, int_height=0, ratio=1, **kwargs) Mesh[source]

Generate the internal part of the pinion

Parameters:
  • ext_radius (float) – given by the attribut _radius of the result of repeat_circular - to avoid interference, it must be smaller than _radius (for instance 0.95 * _radius))
  • int_radius (float) – it is the same radius of the largest radius of the hub part
  • depth (float) – face width
  • pattern – any of ‘full’, ‘circle’, ‘rect’, ‘rounded’
  • int_height (float) – if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height
../_images/gearstructure.png
gearhub(bore_radius, depth, int_height=0, hub_height=None, hub_radius=None, resolution=None, **kwargs) Web[source]

Generate a hub for a pinion part

Parameters:
  • bore_radius (float) – radius of the central bore
  • depth (float) – face width; same parameter for gearexterior and gearstructure
  • int_height (float) – only useful for no hub case, checkout the function gearstructure for more information
  • hub_height (float) – height of the hub
  • hub_radius (float) – external radius of the hub

Note

  • if bore_radius is null, the function will return a top circle and a bottom circle used for geargather function
  • if hub_height is null, the function will return a structure with a bore and without a hub

Bevel gear generation

bevelgear(step: float, z: int, pitch_cone_angle: float, pressure_angle: float = 0.3490658503988659, ka: float = 1, kd: float = 1.25, helix_angle: Optional[float] = None, bore_radius: Optional[float] = None, bore_height: Optional[float] = None, resolution=None)[source]

Generate a bevel gear.

Parameters:
  • step (float) – tooth step over the primitive curve, same as the matching rack step the primitive perimeter is step * z and radius is step * z / (2 * pi)
  • z (int) – number of teeth
  • pitch_cone_angle (float) – pitch cone angle
  • pressure_angle (float) – the pressure angle of the tooth
  • ka (float) – addendum coefficient
  • kd (float) – dedendum coefficient
  • helix_angle (float) – helix angle of the tooth
  • bore_radius (float) – radius of the main bore
  • bore_height (float) – height of the main bore

example:

>>> bevelgear(1, 12, pi/3)
../_images/bevelgear.png

Helper tools

gearcircles(step, z, h=None, offset=0, alpha=0.5235987755982988)[source]

return the convenient circles radius for a gear with the given parameters return is (primitive, base, bottom, top)

involute(c, t0, t)[source]

give a point of parameter t on involute from circle or radius c, starting from t0 on the circle

t and t0 are angular positions

involuteat(c, r)[source]

give the parameter for the involute of circle radius c to reach radius r

involuteof(c, t0, d, t)[source]

give a point of parameter t on involute with offset, from circle or radius c, starting from t0 on the circle

t and t0 are angular positions

spherical_involute(cone_angle: float, t0: float, t: float) dvec3[source]

Return spherical involute function

Parameters:
  • t (float) – the angular position
  • t0 (float) – the difference phase
  • cone_angle (float) – the cone angle
Returns:

a normalized vec3

spherical_involuteof(pitch_cone_angle: float, t0: float, alpha: float, t: float) dvec3[source]

Return the spherical interference function

Parameters:
  • t (float) – the angular position
  • t0 (float) – the difference phase
  • pitch_cone_angle (float) – the pitch cone angle
  • alpha (float) – the height angle offset of the rack
Returns:

a normalized vec3

repeat_circular(profile, n: int) Wire[source]

Repeat n times the given Wire by rotation around (O,Z)

Structure patterns

Those are the functions generating usual structures ready to used in geargather.

pattern_circle(ext_radius, int_radius, depth, int_height=0, ratio=1, patterns: int = 5, circles_radius=None, circles_place=None, **kwargs) Mesh[source]

Generate two parts of the structure (the top and the bottom) with patterns distributed on the whole structure.

Return a tuple (Web, Web, Mesh) where the first Web is the top of the structure, the second Web is the bottom of the structure and the last element Mesh is all side surfaces.

Parameters:
  • ext_radius (float) – radius of the external border of the structure
  • int_radius (float) – radius of the internal border of the structure
  • depth (float) – face width
  • int_height (float) – if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height
  • ratio (float) – number that allows to change proportionally the radius of circles
  • patterns (int) – number of circles of the structure
  • circles_radius (float) – radius of circles
  • circles_place (float) – radius where the origins of circles are placed

Note

  • For instance, with a ratio of 1.5, the radius of circles circles_radius will be divided by 1.5
  • If circles_radius is chosen, ratio won’t impact the radius of circles circles_radius
pattern_full(ext_radius, int_radius, depth, int_height=0, **kwargs) Mesh[source]

Generate two full parts of the structure (the top and the bottom).

Return a tuple (Web, Web, None) where the first Web is the top of the structure and the second Web is the bottom of the structure.

Parameters:
  • ext_radius (float) – float (radius of the external border of the pattern
  • int_radius (float) – radius of the internal border of the pattern
  • depth (float) – face width
  • int_height (float) – if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height
pattern_rect(ext_radius, int_radius, depth, int_height=0, ratio=1, patterns=5, ext_thickness=None, int_thickness=None, **kwargs) Mesh[source]

Generate two parts of the structure (the top and the bottom) with patterns distributed on the whole structure. All corners are straight. Check the function pattern_rounded to get rounded corners.

Return a tuple (Web, Web, Mesh) where the first Web is the top of the structure, the second Web is the bottom of the structure and the last element Mesh is all side surfaces.

Parameters:
  • ext_radius – float (radius of the external border of the structure)
  • int_radius – float (radius of the internal border of the structure)
  • depth – float (face width)
  • int_height – float (if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height)
  • ratio – float (it is a number which is the proportional factor for an homothety of patterns)
  • patterns – int (number of patterns inside the structure)
  • ext_thickness (float) – internal radius of the pattern
  • int_thickness (float) – external radius of the pattern

Note

  • For instance, if ratio is 1.5, the area of the pattern will be divided by 1.5.
  • If r_int and r_ext are chosen, ratio won’t impact these parameters
pattern_rounded(ext_radius, int_radius, depth, int_height=0, ratio=1, patterns: int = 5, ext_thickness=None, int_thickness=None, **kwargs) Mesh[source]

Generate two parts of the structure (the top and the bottom) with patterns distributed on the whole structure. All corners are rounded. Check the function pattern_rect to get straight corners.

Return a tuple (Web, Web, Mesh) where the first Web is the top of the structure, the second Web is the bottom of the structure and the last element Mesh is all side surfaces.

Parameters:
  • ext_radius – float (radius of the external border of the structure)
  • int_radius – float (radius of the internal border of the structure)
  • depth – float (face width)
  • int_height – float (if you want a pinion with a structure thinner than the value of depth, the total height will be total_height = depth - 2 * int_height)
  • ratio – float (it is a number which is the proportional factor for an homothety of patterns)
  • patterns – int (number of patterns inside the structure)
  • ext_thickness (float) – internal radius of the pattern
  • int_thickness (float) – external radius of the pattern

Note

  • For instance, if ratio is 1.5, the area of the pattern will be divided by 1.5.
  • If r_int and r_ext are chosen, ratio won’t impact these parameters