VDampedRotarySpring

Qualified name: manim\_pymunk.constraints.VDampedRotarySpring

class VDampedRotarySpring(a_mob, b_mob, rest_angle=0.0, stiffness=10.0, damping=1.0, arc_indicator_class=<class 'manim.mobject.geometry.arc.Arc'>, arc_indicator_config={'color': ManimColor('#FC6255'), 'radius': 0.1, 'stroke_width': 4}, connect_line_class=None, connect_line_config={'color': ManimColor('#F7D96F'), 'stroke_width': 2}, **kwargs)[source]

Bases: VConstraint

A rotational spring connection is created between the two rigid bodies. When the actual relative angle deviates from the target angle, the spring torque pulls it back; the damping torque dampens the oscillation.

Parameters

a_mob

The first Mobject to be connected. Typically acts as the pivot point or one of the bodies under physical influence.

b_mob

The second Mobject to be connected. It is linked to a_mob via a physical constraint such as a spring or hinge.

rest_angle

The equilibrium angle (in radians). The target angle between the two objects when the system is at rest and no external forces are applied.

stiffness

The spring constant (elasticity). A higher value increases the restorative force toward the rest_angle, making the spring feel “stiffer.”

damping

The damping coefficient. Used to simulate energy dissipation (like friction or air resistance). Higher values cause oscillations to decay faster.

arc_indicator_class

The class used to visualize the angle (defaults to Arc). If set to None, no angular arc will be rendered.

arc_indicator_config

A dictionary defining the visual style of the arc indicator, including radius, color, and stroke_width.

connect_line_class

The class used to draw a connecting line between the two objects (e.g., Line). Defaults to None for no visible connection.

connect_line_config

A dictionary defining the visual style of the connecting line, such as color and stroke_width.

Examples

Example: VDampedRotarySpringExample

from manim import *

from manim_pymunk import *

class VDampedRotarySpringExample(SpaceScene):
    def construct(self):
        floor = Line(LEFT * 10, RIGHT * 10).shift(DOWN*2)

        square_1 = Square().next_to(floor, UP)
        square_2 = Square().move_to(square_1.get_center() + RIGHT * 4)

        constraint = VDampedRotarySpring(
            square_1,
            square_2,
            rest_angle=PI / 4,
            stiffness=100,
            damping=1,
        )

        self.add_static_body(floor)
        self.add_dynamic_body(square_1, square_2)
        self.add_constraints(constraint)

        self.wait(3)
from manim_pymunk import *

class VDampedRotarySpringExample(SpaceScene):
    def construct(self):
        floor = Line(LEFT * 10, RIGHT * 10).shift(DOWN*2)

        square_1 = Square().next_to(floor, UP)
        square_2 = Square().move_to(square_1.get_center() + RIGHT * 4)

        constraint = VDampedRotarySpring(
            square_1,
            square_2,
            rest_angle=PI / 4,
            stiffness=100,
            damping=1,
        )

        self.add_static_body(floor)
        self.add_dynamic_body(square_1, square_2)
        self.add_constraints(constraint)

        self.wait(3)

Methods

install

Initialization of physics and visualization components

mob_updater

Visual control updater

Attributes

always

Call a method on a mobject every frame.

animate

Used to animate the application of any method of self.

animation_overrides

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

n_points_per_curve

sheen_factor

stroke_color

width

The 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, rest_angle=0.0, stiffness=10.0, damping=1.0, arc_indicator_class=<class 'manim.mobject.geometry.arc.Arc'>, arc_indicator_config={'color': ManimColor('#FC6255'), 'radius': 0.1, 'stroke_width': 4}, connect_line_class=None, connect_line_config={'color': ManimColor('#F7D96F'), 'stroke_width': 2}, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • a_mob (Mobject)

  • b_mob (Mobject)

  • rest_angle (float)

  • stiffness (float)

  • damping (float)

  • arc_indicator_class (Arc | None)

  • arc_indicator_config (dict)

  • connect_line_class (Line | None)

  • connect_line_config (dict)

animation_overrides = {}
arc_a: VMobject | None
arc_b: VMobject | None
background_image: Image | str | None
background_stroke_color: ManimColor
background_stroke_opacity: float
background_stroke_width: float
cap_style: CapStyleType
close_new_points: bool
conn_line: VMobject | None
constraint: DampedRotarySpring | None
install(space)[source]

Initialization of physics and visualization components

Parameters:

space (Space)

joint_type: LineJointType
make_smooth_after_applying_functions: bool
mob_updater(mob, dt)[source]

Visual control updater

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)

  • rest_angle (float)

  • stiffness (float)

  • damping (float)

  • arc_indicator_class (Arc | None)

  • arc_indicator_config (dict)

  • connect_line_class (Line | None)

  • connect_line_config (dict)