pyoptools.gui.ipywidgets module

Module with functions and classes to represent the pyoptools objects in jupyter notebooks.

pyoptools.gui.ipywidgets.Plot3D(S, size=(800, 200), center=(0, 0, 0), rot=[(1.0471975511965976, 0.5235987755982988, 0)], scale=1)

Creates a 3D interactive visualization of an optical system, component, or surface within a Jupyter notebook using pythreejs.

This function sets up a 3D scene with the specified object at its center, applying rotation and scaling as defined. It utilizes pythreejs to render the scene, allowing for interactive exploration of the object in 3D space. The visualization includes directional and ambient lighting to enhance the appearance of the object.

Parameters:
  • S (System or Component) – The optical system, component, or surface object to be visualized. This object must be compatible with the pyOpTools framework and capable of being converted into a mesh representation for 3D rendering.

  • size (tuple of float, optional) – The size of the visualization window in the notebook, specified as (width, height) in pixels. Default is (800, 200).

  • center (tuple of float, optional) – The coordinates of the center of the visualization window in the object’s coordinate system, specified as (x, y, z). Default is (0, 0, 0), which centers the view on the origin of the object’s coordinate system.

  • rot (list of tuples, optional) – A list of rotation tuples, each representing a rotation around the x, y, and z axes (in radians). These rotations are applied in sequence to the initial view of the object. Default is [(pi / 3.0, pi / 6.0, 0)], which applies a specific initial rotation to the object.

  • scale (float, optional) – A scale factor applied to the rendered scene, affecting the zoom level of the visualization. Default is 1, which renders the scene at a 1:1 scale.

Returns:

A pythreejs Renderer object that displays the 3D visualization of the specified object within a Jupyter notebook. This renderer is interactive, allowing users to rotate, zoom, and pan the view within the notebook.

Return type:

pythreejs.Renderer

Examples

>>> Plot3D(my_system, size=(800, 600), center=(0, 0, 0),
... rot=[(pi/3, pi/6, 0)], scale=1)
    This example creates a 3D visualization of 'my_system' with a window
    size of 800x600 pixels, centered at the origin, with an initial rotation
    and a scale factor of 1.