Pyqtgraph’s Scene

PyQtGraph 3D scene definition.

Classes:

Scene3D(inertial_frame, zero_point[, view])

Class for plotting sympy mechanics in pyqtgraph.

class symmeplot.pyqtgraph.scene.Scene3D(inertial_frame: sympy.physics.vector.frame.ReferenceFrame, zero_point: sympy.physics.vector.point.Point, view: GLViewWidget | None = None, **inertial_frame_properties: object)

Bases: SceneBase

Class for plotting sympy mechanics in pyqtgraph.

Parameters:

Examples

import sympy.physics.mechanics as me
from symmeplot.pyqtgraph import Scene3D

N = me.ReferenceFrame("N")
A = me.ReferenceFrame("A")
A.orient_axis(N, N.z, 1)
N0 = me.Point("N_0")
v = 0.2 * N.x + 0.2 * N.y + 0.7 * N.z
A0 = N0.locatenew("A_0", v)
scene = Scene3D(N, N0, scale=0.5)
scene.add_vector(v, name="v")
scene.add_frame(A, A0, as_mesh=True)
scene.lambdify_system(())
scene.evaluate_system()
scene.plot()

Methods:

add_body(body, **kwargs)

Add a sympy body to the scene.

add_frame(frame[, origin])

Add a sympy ReferenceFrame to the scene.

add_line(points[, name])

Add a sympy Vector to the scene.

add_plot_object(plot_object)

Add a plot object to the scene.

add_point(point, **kwargs)

Add a sympy Vector to the scene.

add_point_trace(point[, frequency, alpha_decays])

Add a traced point to the scene.

add_vector(vector[, origin])

Add a sympy Vector to the scene.

animate(get_args, frames[, interval])

Animate the scene.

evaluate_system(*args)

Evaluate the system using the function created with lambdify_system.

get_expressions_to_evaluate()

Return a tuple of the necessary expressions for plotting.

get_plot_object(sympy_object)

Return the plot_object based on a sympy object.

lambdify_system(args[, modules, printer, ...])

Lambdify the system.

plot()

Plot all plot objects.

set_visibility(sympy_object, is_visible[, ...])

Hide or show a plot_object based on a sympy_object.

update()

Update the objects on the scene, based on the current values.

Attributes:

artists

Artists used to plot the object.

children

Plot objects.

inertial_frame

The reference frame with respect to which all objects will be oriented.

plot_objects

Plot objects.

values

List of evaluated values for the object's variables.

view

The view in which the scene is plotted.

zero_point

The absolute origin with respect to which all objects will be positioned.

add_body(body: Particle | RigidBody, **kwargs: object) PlotBase

Add a sympy body to the scene.

Parameters:
Returns:

The added plot object.

Return type:

PlotBody

add_frame(frame: ReferenceFrame, origin: Point | Vector | None = None, **kwargs: object) PlotBase

Add a sympy ReferenceFrame to the scene.

Parameters:
Returns:

The added plot object.

Return type:

PlotFrame

add_line(points: Iterable[Point | Vector], name: str | None = None, **kwargs: object) PlotBase

Add a sympy Vector to the scene.

Parameters:
Returns:

The added plot object.

Return type:

PlotLine

add_plot_object(plot_object: PlotBase) None

Add a plot object to the scene.

Parameters:

plot_object (PlotBase) – The plot object that should be added.

add_point(point: Point | Vector, **kwargs: object) PlotBase

Add a sympy Vector to the scene.

Parameters:
Returns:

The added plot object.

Return type:

PlotPoint

add_point_trace(point: Point | Vector, frequency: int = 1, alpha_decays: Callable[[np.ndarray[np.int64]], np.ndarray[np.float64]] | None = None, **kwargs: object) PlotBase

Add a traced point to the scene.

Parameters:
  • point (sympy.physics.vector.point.Point or sympy.physics.vector.vector.Vector) – The point or vector to be traced in space.

  • frequency (int, optional) – Frequency to log the point with. Default is 1 (shows every point).

  • alpha_decays (callable, optional) – Function that returns the transparency of a point based on the number of evaluations since it was logged. This input is an array of integers representing the age of each logged point, and the output should be an array of floats between 0 and 1 representing the alpha values. If None, no transparency decay is applied. Default is None. Hint: you can use np.vectorize to vectorize a function for this purpose.

  • **kwargs – Keyword arguments are parsed to the plot object.

Returns:

The added plot object.

Return type:

PlotTracedPoint

add_vector(vector: Vector, origin: Point | Vector | None = None, **kwargs: object) PlotBase

Add a sympy Vector to the scene.

Parameters:
Returns:

The added plot object.

Return type:

PlotVector

animate(get_args: Callable[[object], tuple], frames: Iterable[object] | int, interval: int = 30) None

Animate the scene.

Parameters:
  • get_args (Callable) – Function that returns the arguments for the evaluate_system method. The function should takes the current frame as input.

  • frames (int or iterable) – Number of frames or iterable with frames.

  • interval (int, optional) – Time interval between frames in milliseconds. Default is 30.

property artists: tuple[ArtistBase, ...]

Artists used to plot the object.

property children: tuple[PlotBase, ...]

Plot objects.

evaluate_system(*args: object) None

Evaluate the system using the function created with lambdify_system.

get_expressions_to_evaluate() tuple

Return a tuple of the necessary expressions for plotting.

get_plot_object(sympy_object: object | str) PlotBase | None

Return the plot_object based on a sympy object.

Explanation

Return the plot_object based on a provided sympy object. For example ReferenceFrame('N') will give the PlotFrame of that reference frame. If the plot_object has not been added it will return None.

Parameters:

sympy_object (object or str) – SymPy object to search for. If it is a string it will search for the name.

Returns:

Retrieved plot object.

Return type:

PlotBase or None

property inertial_frame: sympy.physics.vector.frame.ReferenceFrame

The reference frame with respect to which all objects will be oriented.

lambdify_system(args, modules=None, printer=None, use_imps=True, dummify=False, cse=True) Callable

Lambdify the system.

Explanation

Lambdify the system for faster evaluation, when combined with symmeplot.core.scene.SceneBase.evaluate_system(). See sympy.utilities.lambdify.lambdify() for more information.

plot() None

Plot all plot objects.

property plot_objects: tuple[PlotBase, ...]

Plot objects.

set_visibility(sympy_object: object | str, is_visible: bool, raise_error: bool = True) None

Hide or show a plot_object based on a sympy_object.

Parameters:
update() None

Update the objects on the scene, based on the current values.

property values: tuple

List of evaluated values for the object’s variables.

property view: GLViewWidget

The view in which the scene is plotted.

property zero_point: sympy.physics.vector.point.Point

The absolute origin with respect to which all objects will be positioned.