VSlideJoint

Qualified name: manim\_pymunk.constraints.VSlideJoint

class VSlideJoint(a_mob, b_mob, anchor_a_local=array([0., 0., 0.]), anchor_b_local=array([0., 0., 0.]), min_dist=0.0, max_dist=1.0, anchor_a_appearance=Dot, anchor_b_appearance=Dot, indicator_line_class=<class 'manim.mobject.geometry.line.Line'>, indicator_line_config={'color': ManimColor('#FC6255'), 'stroke_width': 2}, **kwargs)[source]

Bases: VConstraint

Initializes a Slide Joint constraint between two Mobjects.

A Slide Joint holds two bodies between a minimum and maximum distance. It acts like a solid link when the distance reaches the limits, but allows free movement within the specified range.

Parameters

a_mob

The first Mobject to connect.

b_mob

The second Mobject to connect.

anchor_a_local

The anchor point on the first body, defined in local coordinates.

anchor_b_local

The anchor point on the second body, defined in local coordinates.

min_dist

The minimum allowed distance between the two anchor points.

max_dist

The maximum allowed distance between the two anchor points.

anchor_a_appearance

The visual representation (Mobject) of the first anchor point.

anchor_b_appearance

The visual representation (Mobject) of the second anchor point.

indicator_line_class

The Manim class used to draw the connection line (e.g., Line or DashedLine). Pass None to disable the visual indicator.

indicator_line_config

Configuration dictionary for the styling of the indicator line.

Examples

Example: VSlideJointExample

from manim import *

from manim_pymunk import *

class VSlideJointExample(SpaceScene):
    def construct(self):

        static_dot = Dot(ORIGIN)
        square = Square().move_to(static_dot).scale(2)
        square2 = Square().move_to(static_dot.get_center() + UR*3).scale(0.5)

        constraints = [
            VPinJoint(static_dot, square),
            VSlideJoint(
                square,
                square2,
                anchor_a_local=square.get_corner(UR) - square.get_center(),
                min_dist=0.5,
                max_dist=3,
            ),
            VSimpleMotor(
                static_dot,
                square,
                rate=PI/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(6)
from manim_pymunk import *

class VSlideJointExample(SpaceScene):
    def construct(self):

        static_dot = Dot(ORIGIN)
        square = Square().move_to(static_dot).scale(2)
        square2 = Square().move_to(static_dot.get_center() + UR*3).scale(0.5)

        constraints = [
            VPinJoint(static_dot, square),
            VSlideJoint(
                square,
                square2,
                anchor_a_local=square.get_corner(UR) - square.get_center(),
                min_dist=0.5,
                max_dist=3,
            ),
            VSimpleMotor(
                static_dot,
                square,
                rate=PI/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(6)

Methods

install

Installs physical constraints into the Pymunk physical space.

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, anchor_a_local=array([0., 0., 0.]), anchor_b_local=array([0., 0., 0.]), min_dist=0.0, max_dist=1.0, anchor_a_appearance=Dot, anchor_b_appearance=Dot, indicator_line_class=<class 'manim.mobject.geometry.line.Line'>, 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)

  • anchor_a_local (list[float, float, float])

  • anchor_b_local (list[float, float, float])

  • min_dist (float)

  • max_dist (float)

  • anchor_a_appearance (Mobject)

  • anchor_b_appearance (Mobject)

  • 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: SlideJoint | None
install(space)[source]

Installs physical constraints into the Pymunk physical space. This method should be overridden by subclasses to implement the following:

  1. Create Pymunk constraint objects

  2. Initialize the vision component

  3. Add constraints to the physical space

  4. Bind an updater to keep the vision synchronized.

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)

  • anchor_a_local (list[float, float, float])

  • anchor_b_local (list[float, float, float])

  • min_dist (float)

  • max_dist (float)

  • anchor_a_appearance (Mobject)

  • anchor_b_appearance (Mobject)

  • indicator_line_class (Line | None)

  • indicator_line_config (dict)