Motions¶
This module contains functionality related to motions (continuous flexes).
- class pyrigi.motion.Motion(graph)[source]¶
Bases:
object
An abstract class representing a continuous flex of a framework.
- Parameters:
graph (Graph)
- class pyrigi.motion.ParametricMotion(graph, motion, interval)[source]¶
Bases:
Motion
Class representing a parametric motion.
Definitions
- Parameters:
Examples
>>> from pyrigi.motion import ParametricMotion >>> import sympy as sp >>> from pyrigi import graphDB as graphs >>> motion = ParametricMotion( ... graphs.Cycle(4), ... { ... 0: ("0", "0"), ... 1: ("1", "0"), ... 2: ("4 * (t**2 - 2) / (t**2 + 4)", "12 * t / (t**2 + 4)"), ... 3: ( ... "(t**4 - 13 * t**2 + 4) / (t**4 + 5 * t**2 + 4)", ... "6 * (t**3 - 2 * t) / (t**4 + 5 * t**2 + 4)", ... ), ... }, ... [-sp.oo, sp.oo], ... ) >>> motion ParametricMotion of a Graph with vertices [0, 1, 2, 3] and edges [[0, 1], [0, 3], [1, 2], [2, 3]] with motion defined for every vertex: 0: Matrix([[0], [0]]) 1: Matrix([[1], [0]]) 2: Matrix([[(4*t**2 - 8)/(t**2 + 4)], [12*t/(t**2 + 4)]]) 3: Matrix([[(t**4 - 13*t**2 + 4)/(t**4 + 5*t**2 + 4)], [(6*t**3 - 12*t)/(t**4 + 5*t**2 + 4)]])
- animate(width=500, height=500, filename=None, sampling=50, show_labels=True, vertex_size=5, duration=8)[source]¶
Animate the parametric motion.
- Parameters:
width (int) – The width of the window in the svg file.
height (int) – The height of the window in the svg file.
filename (str | None) – A name used to store the svg. If
None`
, the svg is not saved.sampling (int) – The number of discrete points or frames used to approximate the motion in the animation. A higher value results in a smoother and more accurate representation of the motion, while a lower value can speed up rendering but may lead to a less precise or jerky animation. This parameter controls the resolution of the animation’s movement by setting the density of sampled data points between keyframes or time steps.
show_labels (bool) – If
True
, the vertices will have a number label.vertex_size (int) – The size of vertices in the animation.
duration (int) – The duration of one period of the animation in seconds.
- Return type:
None