VPinJoint

Qualified name: manim\_pymunk.constraints.VPinJoint

class VPinJoint(a_mob, b_mob, anchor_a_local=array([0., 0., 0.]), anchor_b_local=array([0., 0., 0.]), distance=None, anchor_a_appearance=Dot, anchor_b_appearance=Dot, connect_line_class=None, connect_line_config={'color': ManimColor('#F7D96F'), 'stroke_width': 2}, **kwargs)[source]

Bases: VConstraint

A pin joint keeps a fixed distance between two anchor points on two rigid bodies. It acts like a solid, weightless rod connecting two points, allowing them to rotate freely around the anchors while maintaining the specified distance.

Parameters

a_mob

The first Mobject to be connected.

b_mob

The second Mobject to be connected.

anchor_a_local

The local anchor point on a_mob where the pin is attached, relative to the Mobject’s center.

anchor_b_local

The local anchor point on b_mob where the pin is attached, relative to the Mobject’s center.

distance

The fixed distance to maintain between the two anchors. If None, it is automatically calculated as the initial distance between anchors.

anchor_a_appearance

The Mobject used to visually represent the anchor point on a_mob (e.g., a red Dot).

anchor_b_appearance

The Mobject used to visually represent the anchor point on b_mob (e.g., a red Dot).

connect_line_class

The class used to draw the connecting rod (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: VPinJointExample

from manim import *

from manim_pymunk import *

class VPinJointExample(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,
            ),
        ]

        self.add_static_body(static_dot)
        self.add_dynamic_body(square, square2, angular_velocity=PI * 2)
        self.add_shapes_filter(static_dot, square, square2, group=2)
        self.add_constraints(*constraints)
        self.wait(3)
from manim_pymunk import *

class VPinJointExample(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,
            ),
        ]

        self.add_static_body(static_dot)
        self.add_dynamic_body(square, square2, angular_velocity=PI * 2)
        self.add_shapes_filter(static_dot, square, square2, group=2)
        self.add_constraints(*constraints)
        self.wait(3)

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.]), distance=None, anchor_a_appearance=Dot, anchor_b_appearance=Dot, 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)

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

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

  • distance (float | None)

  • anchor_a_appearance (Mobject)

  • anchor_b_appearance (Mobject)

  • connect_line_class (Line | None)

  • connect_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: PinJoint | 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])

  • distance (float | None)

  • anchor_a_appearance (Mobject)

  • anchor_b_appearance (Mobject)

  • connect_line_class (Line | None)

  • connect_line_config (dict)