VSimpleMotor¶
Qualified name: manim\_pymunk.constraints.VSimpleMotor
- class VSimpleMotor(a_mob, b_mob, rate=3.141592653589793, max_torque=inf, indicator_line_class=<class 'manim.mobject.geometry.line.Arrow'>, indicator_line_config={'color': ManimColor('#FC6255'), 'stroke_width': 2}, **kwargs)[source]¶
Bases:
VConstraintInitializes a Simple Motor constraint between two Mobjects.
A Simple Motor maintains a constant relative angular velocity between two bodies. It applies the necessary torque to reach and maintain the target rotation rate, up to a defined maximum torque limit.
Parameters¶
- a_mob
The first Mobject (often the base or stator).
- b_mob
The second Mobject (often the rotor or driven part).
- rate
The target relative angular velocity in radians per second.
- max_torque
The maximum torque the motor can apply to achieve the target rate. Setting this to a finite value allows the motor to “stall” under load.
- indicator_line_class
The Manim class used to visualize the rotation (e.g., Arrow or CurvedArrow).
- indicator_line_config
Configuration dictionary for the styling of the visual indicator.
Examples¶
Example: VSimpleMotorExample ¶
from manim import * from manim_pymunk import * class VSimpleMotorExample(SpaceScene): def construct(self): static_dot = Dot(ORIGIN) square = Square().move_to(static_dot) square2 = Square().move_to(static_dot.get_center() + UP * 2).scale(0.5) constraints = [ VPinJoint(static_dot, square), VPinJoint( square, square2, anchor_a_local=square.get_corner(UR) - square.get_center(), distance=2, connect_line_class=Line, ), VSimpleMotor( static_dot, square, rate=4, max_torque=500, ), ] self.add_static_body(static_dot) self.add_dynamic_body(square, square2) self.add_shapes_filter(static_dot, square, square2, group=2) self.add_constraints(*constraints) self.wait(3)
from manim_pymunk import * class VSimpleMotorExample(SpaceScene): def construct(self): static_dot = Dot(ORIGIN) square = Square().move_to(static_dot) square2 = Square().move_to(static_dot.get_center() + UP * 2).scale(0.5) constraints = [ VPinJoint(static_dot, square), VPinJoint( square, square2, anchor_a_local=square.get_corner(UR) - square.get_center(), distance=2, connect_line_class=Line, ), VSimpleMotor( static_dot, square, rate=4, max_torque=500, ), ] self.add_static_body(static_dot) self.add_dynamic_body(square, square2) self.add_shapes_filter(static_dot, square, square2, group=2) self.add_constraints(*constraints) self.wait(3)Methods
installInstalls physical constraints into the Pymunk physical space.
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.
- __check_data()¶
Verify the validity of constraint parameters.
- _abc_impl = <_abc._abc_data object>¶
- _bezier_t_values: npt.NDArray[float]¶
- _original__init__(a_mob, b_mob, rate=3.141592653589793, max_torque=inf, indicator_line_class=<class 'manim.mobject.geometry.line.Arrow'>, indicator_line_config={'color': ManimColor('#FC6255'), 'stroke_width': 2}, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
a_mob (Mobject)
b_mob (Mobject)
rate (float)
max_torque (float)
indicator_line_class (Line | None)
indicator_line_config (dict)
- 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: SimpleMotor | None¶
- install(space)[source]¶
Installs physical constraints into the Pymunk physical space. This method should be overridden by subclasses to implement the following:
Create Pymunk constraint objects
Initialize the vision component
Add constraints to the physical space
Bind an updater to keep the vision synchronized.
- Parameters:
space (Space)
- 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)
rate (float)
max_torque (float)
indicator_line_class (Line | None)
indicator_line_config (dict)