Classes

class manim_extensions.gearbox.Gear(num_of_teeth, module=0.2, alpha=20, h_a=1, h_f=1.2, inner_teeth=False, profile_shift=0, cutout_teeth_num=0, nppc=5, **kwargs)[source]

Bases: VMobject

A Manim mobject representing an involute gear.

The gear is constructed from involute curves and can mesh with other Gear objects (or Rack objects) using mesh_to().

Two gears mesh correctly when they share the same module and alpha (pressure angle). The pitch-circle radius of a gear is module * num_of_teeth / 2.

Inheritance diagram of manim_extensions.gearbox.Gear

Parameters:
  • num_of_teeth (int) – Number of gear teeth.

  • module (float, optional) – Standard size scaling parameter. diameter = module * num_of_teeth. Defaults to 0.2.

  • alpha (float, optional) – Pressure angle in degrees. Affects tooth curvature. Suggested values are between 10 and 30. Defaults to 20.

  • h_a (float, optional) – Addendum coefficient (tooth height above the pitch circle). Defaults to 1.

  • h_f (float, optional) – Dedendum coefficient (tooth height below the pitch circle). Defaults to 1.2.

  • inner_teeth (bool, optional) – If True, generate a ring gear with teeth pointing inward. Defaults to False.

  • profile_shift (float, optional) – Profile-shift coefficient. Changes the tooth shape and diameter slightly and reduces undercut. Defaults to 0.

  • cutout_teeth_num (int, optional) – Number of teeth to omit. Defaults to 0.

  • nppc (int, optional) – Number of points per involute curve. One tooth is built from four to six curve pieces depending on undercut. Defaults to 5.

  • **kwargs – Additional keyword arguments forwarded to VMobject.

Examples

Example: GearDocExample

from manim import *
from manim_extensions.gearbox import Gear

class GearDocExample(Scene):
    def construct(self):
        gear1 = Gear(15, stroke_opacity=0, fill_color=WHITE, fill_opacity=1)
        gear2 = Gear(25, stroke_opacity=0, fill_color=RED, fill_opacity=1)
        gear1.shift(-gear1.rp * 1.5 * RIGHT)
        gear2.mesh_to(gear1)

        self.add(gear1, gear2)
        self.play(
            Rotate(gear1, gear1.pitch_angle, rate_func=linear),
            Rotate(gear2, -gear2.pitch_angle, rate_func=linear),
            run_time=4,
        )
        self.wait()
from manim import *
from manim_extensions.gearbox import Gear

class GearDocExample(Scene):
    def construct(self):
        gear1 = Gear(15, stroke_opacity=0, fill_color=WHITE, fill_opacity=1)
        gear2 = Gear(25, stroke_opacity=0, fill_color=RED, fill_opacity=1)
        gear1.shift(-gear1.rp * 1.5 * RIGHT)
        gear2.mesh_to(gear1)

        self.add(gear1, gear2)
        self.play(
            Rotate(gear1, gear1.pitch_angle, rate_func=linear),
            Rotate(gear2, -gear2.pitch_angle, rate_func=linear),
            run_time=4,
        )
        self.wait()

__init__(num_of_teeth, module=0.2, alpha=20, h_a=1, h_f=1.2, inner_teeth=False, profile_shift=0, cutout_teeth_num=0, nppc=5, **kwargs)[source]

Create an involute gear. See the class docstring for parameter details.

get_center()[source]

Return the geometric center of the gear.

get_angle_vector()[source]

Return the internal reference vector used to track rotation.

get_angle()[source]

Return the current rotation angle of the gear in radians.

set_stroke(color=None, **kwargs)[source]

Override set_stroke to avoid revealing the line which is used for tracking center and angle. If family is specified, it will still do it.

generate_points()[source]

Build the gear outline from involute curves, fillets, and arcs.

mesh_to(gear2, offset=0, bias=1)[source]

This will position and rotate the gear (self) next to the input gear2 so that they mesh properly.

Parameters:
  • gear2 (Gear)

  • offset (float)

  • positive_bias (When offset is used, there will play between gears. If positive_bias= True,) – this function meshes ‘self’ gear to gear2 as if there was a positive rotation torque on ‘self’.

rotate(angle, axis=array([0., 0., 1.]), about_point=None, **kwargs)[source]

Override of original rotate function so that if about_point is not specified, use the gear center

class manim_extensions.gearbox.Rack(num_of_teeth, module=0.2, alpha=20, h_a=1, h_f=1.17, **kwargs)[source]

Bases: VMobject

A Manim mobject representing a rack for involute gears.

The rack must use the same module and pressure angle as the mating gear for proper meshing.

Example: RackExample

../../_images/RackExample-1.png
from manim import *

from manim_extensions.gearbox import Gear, Rack

class RackExample(Scene):
    def construct(self):
        gear = Gear(15, stroke_opacity=0, fill_color=WHITE, fill_opacity=1)
        rack = Rack(12, module=gear.m, stroke_opacity=0, fill_color=RED, fill_opacity=1)
        gear.shift(RIGHT * gear.rp)
        rack.shift(UP * rack.pitch * 0.5)

        self.add(gear, rack)
from manim import *
from manim_extensions.gearbox import Gear, Rack

class RackExample(Scene):
    def construct(self):
        gear = Gear(15, stroke_opacity=0, fill_color=WHITE, fill_opacity=1)
        rack = Rack(12, module=gear.m, stroke_opacity=0, fill_color=RED, fill_opacity=1)
        gear.shift(RIGHT * gear.rp)
        rack.shift(UP * rack.pitch * 0.5)

        self.add(gear, rack)

__init__(num_of_teeth, module=0.2, alpha=20, h_a=1, h_f=1.17, **kwargs)[source]

Basic rack for involute gears (pinion-rack connection). Must have the same module and alpha as the gear for proper meshing.

Parameters:
  • num_of_teeth (number of gear teeth.)

  • module (standard size scaling parameter. Diameter = module * num_of_teeth.)

  • alpha (pressure angle in degrees, affects tooth curvature. Suggested values between 10-30)

  • h_a (addendum / module coefficient (tooth height above pitch circle))

  • h_f (dedendum / module coefficient (tooth height below pitch circle))

generate_points()[source]

Build the rack outline from trapezoidal teeth.

get_center()[source]

Return the geometric center of the rack.

get_angle_vector()[source]

Return the internal reference vector used to track orientation.

get_angle()[source]

Return the current orientation angle of the rack in radians.

rotate(angle, axis=array([0., 0., 1.]), about_point=None, **kwargs)[source]

Override of original rotate function so that if about_point is not specified, use the gear center