capytaine.ui.vtk.animation module

VTK animation for the free surface elevation.

class capytaine.ui.vtk.animation.Animation(loop_duration, fps=24)[source]

Bases: object

Class to generate an animation of a result of Capytaine, including the elevation of the free surface.

The animation is made of a short loop of a single period of the solution in frequency domain.

Parameters:
  • loop_duration (float) – Duration in the loop. For real time animation, the period of the motion.

  • fps (int, optional) – Number of frames per second in the animation (default: 24).

Variables:
  • frames_per_loop (int) – Number of frames in one loop

  • actors (list of vtk actor objects) – The objects in the scene.

add_body(body, faces_motion=None, faces_colors=None, edges=False)[source]

Add an floating body to the scene.

Parameters:
  • body (FloatingBody) – The object to include in the scene.

  • faces_motion (dof, optional) – The motion of the body defined at the center of the faces.

  • faces_colors (iterable of complex numbers, optional) – Scalar field over the surface of the body that should be displayed with colors.

  • edges (bool, optional) – Draw the edges of the mesh in the scene.

Return type:

vtk actor object

add_free_surface(free_surface, faces_elevation)[source]

Add the free surface to the scene.

Parameters:
  • free_surface (FreeSurface) – The free surface object

  • faces_elevation (array of complex numbers) – The elevation of each face of the meshed free surface given as a complex number.

Return type:

vtk actor object

embed_in_notebook(resolution=(640, 360), **kwargs)[source]
run(camera_position=(-10.0, -10.0, 10.0), resolution=(1280, 720))[source]

Run the animation.

Parameters:
  • camera_position (3-ple of floats, optional) – The starting position of the camera in the scene.

  • resolution (2-ple of ints, optional) – Resolution of the video in pixels.

save(filepath, nb_loops=1, camera_position=(-10.0, -10.0, 10.0), resolution=(1280, 720))[source]

Save the animation in a video file.

Parameters:
  • filepath (string) – Path of the output file.

  • nb_loop (int, optional) – Number of periods to save in the file.

  • camera_position (3-ple of floats, optional) – The starting position of the camera in the scene.

  • resolution (2-ple of ints, optional) – Resolution of the video in pixels.