Mechanical Visualizations
Function overview
Generates a spring shape as a Manim VGroup between two points. |
|
Generates a damper shape as a Manim VGroup between two points. |
|
Combines a spring and a damper between two points. |
|
Generates a fixed-world shape as a Manim VGroup between two points with diagonal support lines. |
|
Generates a mass object as a rectangle with centered text. |
|
Generates a mass object as a circle with centered text. |
Detailed Documentation
- spring(start=array([0., 0., 0.]), end=array([0., 3., 0.]), num_coils=6, coil_width=0.4, type='zigzag', **kwargs)[source]
Generates a spring shape as a Manim VGroup between two points.
- Parameters:
start (np.ndarray) – The start point of the spring.
end (np.ndarray) – The end point of the spring.
num_coils (int) – Number of coils in the spring. Must be a positive integer.
coil_width (float) – Width of the coils.
type (str) – Type of spring shape to generate: either “zigzag” or “helical”.
color (Color) – Color of the spring.
**kwargs (Any) – Additional parameters passed to Manim’s Line and VMobject constructors.
- Returns:
A Manim VGroup containing the constructed spring.
- Return type:
VGroup
- damper(start=array([0., 0., 0.]), end=array([0., 3., 0.]), width=0.5, fluid_color=ManimColor('#58C4DD'), **kwargs)[source]
Generates a damper shape as a Manim VGroup between two points.
- Parameters:
start (np.ndarray | Sequence[float]) – The start point of the damper.
end (np.ndarray | Sequence[float]) – The end point of the damper.
width (float) – Width of the damper box.
fluid_color (ManimColor | None) – Color of the fluid. If None, defaults to a predefined color.
**kwargs (Any) – Additional keyword arguments passed to Manim’s Line constructor (e.g., stroke_width, opacity).
- Returns:
A Manim VGroup containing the damper box and damper rod.
- Return type:
VGroup
- springdamper(start=array([0., 0., 0.]), end=array([0., 3., 0.]), num_coils=6, type='zigzag', width=0.5, fluid_color=ManimColor('#58C4DD'), inline=True, **kwargs)[source]
Combines a spring and a damper between two points.
- Parameters:
start (np.ndarray) – Start point of the combined element.
end (np.ndarray) – End point of the combined element.
num_coils (int) – Number of coils in the spring.
type (str) – Spring type (“zigzag” or “helical”).
width (float) – Common width for both spring (2 * coil_width) and damper.
fluid_color (Color) – Fill color of the damper’s fluid.
inline (bool) – If True, overlap spring and damper. If False, place them side by side.
**kwargs (dict) – Additional stroke/fill options.
- Returns:
Combined spring and damper.
- Return type:
VGroup
- fixed_world(start=array([-2., 0., 0.]), end=array([2., 0., 0.]), spacing=None, mirror=False, line_or='right', diag_line_length=0.3, **kwargs)[source]
Generates a fixed-world shape as a Manim VGroup between two points with diagonal support lines.
- Parameters:
start (np.ndarray) – The start point of the fixed-world line.
end (np.ndarray) – The end point of the fixed-world line.
spacing (float | None, optional) – Distance between the diagonal support lines. If None, it is automatically calculated.
mirror (bool, optional) – Whether to mirror the diagonal lines across the main line.
diag_line_length (float, optional) – Length of the diagonal hatch lines.
line_or (str, optional) – Direction of diagonal lines: “right” (default) or “left”.
color (Color) – Color of the main and diagonal lines.
**kwargs (Any) – Additional keyword arguments passed to Manim’s Line constructor (e.g., stroke_width, opacity).
- Returns:
A Manim VGroup containing the ceiling line and the diagonal support lines.
- Return type:
VGroup
- rect_mass(pos=array([0., 0., 0.]), width=1.5, height=1.5, font_size=None, label='m', label_color=ManimColor('#FFFFFF'), **kwargs)[source]
Generates a mass object as a rectangle with centered text.
- Parameters:
pos (np.ndarray | Sequence[float]) – The position of the center of mass.
width (float) – Width of the rectangular mass.
height (float) – Height of the rectangular mass.
font_size (float | None) – Font size of the mass label. If None, scaled proportionally to height.
label (str) – Text displayed inside the mass.
label_color (Color) – Color of the label.
**kwargs (Any) – Additional arguments passed to the Rectangle constructor (e.g., stroke_width, fill_color, fill_opacity).
- Returns:
A Manim VGroup containing the rectangular mass and its label.
- Return type:
VGroup
- circ_mass(pos=array([0., 0., 0.]), radius=1.5, font_size=None, label='m', label_color=ManimColor('#FFFFFF'), **kwargs)[source]
Generates a mass object as a circle with centered text.
- Parameters:
pos (np.ndarray | Sequence[float]) – The position of the center of mass.
radius (float) – Radius of the circular mass.
font_size (float | None) – Font size of the mass label. If None, scaled proportionally to radius.
label (str) – Text displayed inside the mass.
label_color (Color) – Color of the label
**kwargs (Any) – Additional arguments passed to the Circle constructor (e.g., stroke_width, fill_color, fill_opacity).
- Returns:
A Manim VGroup containing the circular mass and its label.
- Return type:
VGroup