GearBox¶
Original author: GarryBGoode
Source repository: GitHub
License: MIT (see the upstream repository for the full license text)
GearBox is a Manim plugin for drawing realistic involute gears and
mechanisms. The geometry is based on the tec-science involute gear article.
The code is bundled inside manim_extensions as the manim_extensions.gearbox
subpackage and is also kept as a Git submodule under third_party/.
Features¶
Quick start¶
Because the module is included in manim_extensions, you can import it
directly (from manim_extensions.gearbox import *). A common rendering
style is stroke_opacity=0 and fill_opacity=1, because the stroke
slightly enlarges the gear and can look like interference.
Two meshing gears¶
Example: GearExample ¶
from manim import *
from manim_extensions.gearbox import Gear
class GearExample(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,
)
from manim import *
from manim_extensions.gearbox import Gear
class GearExample(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,
)
Inner ring gear¶
Example: InnerGearExample ¶
from manim import *
from manim_extensions.gearbox import Gear
class InnerGearExample(Scene):
def construct(self):
gear1 = Gear(
12, module=1, profile_shift=0.3,
stroke_opacity=0, fill_color=WHITE, fill_opacity=1,
)
gear2 = Gear(
36, module=1, inner_teeth=True, profile_shift=0.1,
stroke_opacity=0, fill_color=RED, fill_opacity=1,
)
gear1.shift(gear1.rp * UP)
gear2.shift(gear2.rp * UP)
gear2.mesh_to(gear1, offset=0.15, bias=False)
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,
)
from manim import *
from manim_extensions.gearbox import Gear
class InnerGearExample(Scene):
def construct(self):
gear1 = Gear(
12, module=1, profile_shift=0.3,
stroke_opacity=0, fill_color=WHITE, fill_opacity=1,
)
gear2 = Gear(
36, module=1, inner_teeth=True, profile_shift=0.1,
stroke_opacity=0, fill_color=RED, fill_opacity=1,
)
gear1.shift(gear1.rp * UP)
gear2.shift(gear2.rp * UP)
gear2.mesh_to(gear1, offset=0.15, bias=False)
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,
)
See the original README for animated examples and further details.