VGrooveJoint¶
Qualified name: manim\_pymunk.constraints.VGrooveJoint
- class VGrooveJoint(a_mob, b_mob, groove_a_local=array([1., 0., 0.]), groove_b_local=array([2., 0., 0.]), anchor_b_local=array([0., 0., 0.]), groove_a_appearance=Dot, groove_b_appearance=Dot, anchor_b_appearance=Dot, groove_line_class=<class 'manim.mobject.geometry.line.Line'>, groove_line_config={'color': ManimColor('#F7D96F'), 'stroke_width': 2}, **kwargs)[source]¶
Bases:
VConstraintInitializes a Groove Joint constraint between two Mobjects.
A Groove Joint constrains a point on the second body to a line segment (the “groove”) on the first body. The groove is defined by two points relative to the first body’s center, and the anchor point is relative to the second body’s center.
Parameters¶
- a_mob
The Mobject that contains the groove (the rail/track).
- b_mob
The Mobject that contains the sliding anchor (the slider).
- groove_a_local
The start point of the groove, in a_mob’s local coordinates.
- groove_b_local
The end point of the groove, in a_mob’s local coordinates.
- anchor_b_local
The anchor point on b_mob that slides within the groove, in local coordinates.
- groove_a_appearance
Visual Mobject representing the start of the groove.
- groove_b_appearance
Visual Mobject representing the end of the groove.
- anchor_b_appearance
Visual Mobject representing the sliding anchor on the second body.
- groove_line_class
The Manim class used to draw the groove line (e.g., Line or DashedLine).
- groove_line_config
Configuration dictionary for the styling of the groove line.
Examples¶
Example: VGrooveJointExample ¶
from manim import * from manim_pymunk import * class VGrooveJointExample(SpaceScene): def construct(self): static_dot = Dot() square_1 = Square().move_to(static_dot) square_2 = Square().move_to(static_dot.get_center() + RIGHT * 4).scale(0.3) constraints = [ VGrooveJoint( square_1, square_2, groove_a_local=RIGHT * 2, groove_b_local=RIGHT * 4, ), VPinJoint(static_dot, square_1), ] self.add_static_body(static_dot) self.add_dynamic_body(square_1, angular_velocity=PI * 2) self.add_dynamic_body(square_2) self.add_shapes_filter(static_dot, square_1, square_2, group=2) self.add_constraints(*constraints) self.wait(6)
from manim_pymunk import * class VGrooveJointExample(SpaceScene): def construct(self): static_dot = Dot() square_1 = Square().move_to(static_dot) square_2 = Square().move_to(static_dot.get_center() + RIGHT * 4).scale(0.3) constraints = [ VGrooveJoint( square_1, square_2, groove_a_local=RIGHT * 2, groove_b_local=RIGHT * 4, ), VPinJoint(static_dot, square_1), ] self.add_static_body(static_dot) self.add_dynamic_body(square_1, angular_velocity=PI * 2) self.add_dynamic_body(square_2) self.add_shapes_filter(static_dot, square_1, square_2, group=2) self.add_constraints(*constraints) self.wait(6)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, groove_a_local=array([1., 0., 0.]), groove_b_local=array([2., 0., 0.]), anchor_b_local=array([0., 0., 0.]), groove_a_appearance=Dot, groove_b_appearance=Dot, anchor_b_appearance=Dot, groove_line_class=<class 'manim.mobject.geometry.line.Line'>, groove_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)
groove_a_local (list[float, float, float])
groove_b_local (list[float, float, float])
anchor_b_local (list[float, float, float])
groove_a_appearance (Mobject)
groove_b_appearance (Mobject)
anchor_b_appearance (Mobject)
groove_line_class (Line | None)
groove_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: GrooveJoint | 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)
groove_a_local (list[float, float, float])
groove_b_local (list[float, float, float])
anchor_b_local (list[float, float, float])
groove_a_appearance (Mobject)
groove_b_appearance (Mobject)
anchor_b_appearance (Mobject)
groove_line_class (Line | None)
groove_line_config (dict)