VGearJoint¶
Qualified name: manim\_pymunk.constraints.VGearJoint
- class VGearJoint(a_mob, b_mob, phase=0.0, ratio=1.0, indicator_line_class=<class 'manim.mobject.geometry.line.Arrow'>, indicator_line_config={'color': ManimColor('#58C4DD'), 'stroke_width': 2}, indicator_length=0.4, **kwargs)[source]¶
Bases:
VConstraintA gear joint constrains the rotational speeds of two rigid bodies. It ensures that the two bodies rotate relative to each other at a fixed ratio, simulating the mechanical link of a gear system or a belt drive.
Parameters¶
- a_mob
The first Mobject to be connected. Typically represents the driving or reference gear.
- b_mob
The second Mobject to be connected. Its rotation is linked to a_mob based on the defined ratio.
- phase
The angular offset (in radians) between the two bodies. Adjusts the initial relative orientation alignment.
- ratio
The gear ratio. Defines how the angular velocity of b_mob relates to a_mob. For example, a ratio of 2.0 means b_mob rotates twice as fast as a_mob.
- indicator_line_class
The class used to visualize the rotational direction or connection (defaults to Arrow). If set to None, no indicator will be rendered.
- indicator_line_config
A dictionary defining the visual style of the indicator line, including color and stroke_width.
Examples¶
Example: VGearJointExample ¶
from manim import * from manim_pymunk import * class VGearJointExample(SpaceScene): def construct(self): floor = Line(LEFT * 10, RIGHT * 10).shift(DOWN * 2) static_dot1 = Dot(UP * 2) static_dot2 = Dot(UP * 2 + RIGHT * 4) square_1 = Square().move_to(static_dot1) square_2 = Square().move_to(static_dot2) constraints = [ VGearJoint( square_1, square_2, phase=0, ratio=4, ), VPinJoint(static_dot1, square_1), VPinJoint(static_dot2, square_2), ] self.add_static_body(floor, static_dot1, static_dot2) self.add_dynamic_body(square_1, angular_velocity=PI * 2) self.add_dynamic_body(square_2) self.add_shapes_filter(static_dot1, static_dot2, square_1, square_2, group=2) self.add_constraints(*constraints) self.wait(3)
from manim_pymunk import * class VGearJointExample(SpaceScene): def construct(self): floor = Line(LEFT * 10, RIGHT * 10).shift(DOWN * 2) static_dot1 = Dot(UP * 2) static_dot2 = Dot(UP * 2 + RIGHT * 4) square_1 = Square().move_to(static_dot1) square_2 = Square().move_to(static_dot2) constraints = [ VGearJoint( square_1, square_2, phase=0, ratio=4, ), VPinJoint(static_dot1, square_1), VPinJoint(static_dot2, square_2), ] self.add_static_body(floor, static_dot1, static_dot2) self.add_dynamic_body(square_1, angular_velocity=PI * 2) self.add_dynamic_body(square_2) self.add_shapes_filter(static_dot1, static_dot2, square_1, square_2, group=2) self.add_constraints(*constraints) self.wait(3)Methods
installVerify the validity of constraint parameters.
mob_updaterVisual control updater
Attributes
alwaysCall a method on a mobject every frame.
animateUsed to animate the application of any method of
self.animation_overridescolordepthThe depth of the mobject.
fill_colorIf there are multiple colors (for gradient) this returns the first one
heightThe height of the mobject.
n_points_per_curvesheen_factorstroke_colorwidthThe width of the mobject.
- _abc_impl = <_abc._abc_data object>¶
- _bezier_t_values: npt.NDArray[float]¶
- _original__init__(a_mob, b_mob, phase=0.0, ratio=1.0, indicator_line_class=<class 'manim.mobject.geometry.line.Arrow'>, indicator_line_config={'color': ManimColor('#58C4DD'), 'stroke_width': 2}, indicator_length=0.4, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
a_mob (Mobject)
b_mob (Mobject)
phase (float)
ratio (float)
indicator_line_class (Line | None)
indicator_line_config (dict)
indicator_length (float)
- animation_overrides = {}¶
- background_image: Image | str | None¶
- background_stroke_color: ManimColor¶
- background_stroke_opacity: float¶
- background_stroke_width: float¶
- cap_style: CapStyleType¶
- close_new_points: bool¶
- constraint: GearJoint | None¶
- joint_type: LineJointType¶
- make_smooth_after_applying_functions: bool¶
- n_points_per_cubic_curve: int¶
- pre_function_handle_to_anchor_scale_factor: float¶
- shade_in_3d: bool¶
- submobjects: list[VMobject]¶
- tolerance_for_point_equality: float¶
- Parameters:
a_mob (Mobject)
b_mob (Mobject)
phase (float)
ratio (float)
indicator_line_class (Line | None)
indicator_line_config (dict)
indicator_length (float)