src.core package#

Subpackages#

Submodules#

src.core.core module#

class src.core.core.Object3D(name: str, stl_mesh: Mesh, translation_transform: Translation_Transform, rotation_transform: Rotation_Transform, flexibility_transform: Flexibility_Transform)[source]#

Bases: object

Object3D Class#

A class representing a 3D object with a mesh that can undergo transformations including flexibility, rotation, and translation.

This class allows for the application of transformations to the mesh of a 3D object, which can include deformations (flexibility), rotations, and translations. The transformations are applied sequentially to the mesh data, and the transformed mesh is returned.

name#

The name of the 3D object.

Type:

str

stl_mesh#

The mesh of the 3D object, typically in the form of an STL file.

Type:

mesh.Mesh

translation_transform#

The transformation applied to the object for translation.

Type:

Translation_Transform

rotation_transform#

The transformation applied to the object for rotation.

Type:

Rotation_Transform

flexibility_transform#

The transformation applied to the object for flexibility (deformation).

Type:

Flexibility_Transform

__init__(name, stl_mesh, translation_transform, rotation_transform, flexibility_transform):

Initializes the 3D object with its name, mesh, and transformation functions.

transform(position, angles, t):

Transforms the mesh by applying flexibility, rotation, and translation transformations at a given time.

transform(position, angles, t)[source]#

Apply the specified transformations (flexibility, rotation, translation) to the mesh.

This method applies the flexibility transformation, followed by the rotation and translation transformations to the mesh vertices. The transformed mesh is then returned.

Parameters:
  • position (np.array of shape (3,)) – The translation vector specifying the position (x, y, z) at time t.

  • angles (np.array of shape (3,)) – The rotation angles (alpha, beta, gamma) at time t.

  • t (float) – The current time, used to compute the flexibility transformation.

Returns:

  • mesh.Mesh – A new mesh object with the applied transformations (flexibility, rotation, translation).

  • Methods Called

  • ————–

  • flexibility_transform() – Applies the flexibility transformation to the mesh vertices.

  • rotation_transform() – Applies the rotation transformation to the mesh vertices.

  • translation_transform() – Applies the translation transformation to the mesh vertices.

class src.core.core.Scene(objects: list)[source]#

Bases: object

Scene Class#

A class representing a 3D scene containing multiple sprite objects that can be transformed over time. Each sprite in the scene is an instance of the Sprite class, and the transformations applied to the scene depend on the time step.

This class provides a transform method to apply transformations to each sprite in the scene, either returning their original or transformed meshes based on the time step.

objects#

A list of Sprite objects that make up the 3D scene.

Type:

list of Sprite

__init__(objects):

Initializes the scene with a list of Sprite objects.

transform(t):

Applies transformations to all sprite objects in the scene at the given time step t.

save_stl(t, reflect_xy=False, reflect_yz=False, reflect_xz=False)[source]#

Save the transformed meshes to STL files with optional reflections.

This method applies transformations to all objects in the scene at the given time step t. If reflection flags are set (e.g., reflect_xy, reflect_yz, or reflect_xz), it applies the corresponding reflection to the objects in the scene. The method then combines the transformed meshes and their reflected versions into a single mesh and returns it.

Parameters:
  • t (float) – The time step used to apply transformations to the objects in the scene.

  • reflect_xy (bool, optional) – If set to True, the objects are reflected across the xy-plane.

  • reflect_yz (bool, optional) – If set to True, the objects are reflected across the yz-plane.

  • reflect_xz (bool, optional) – If set to True, the objects are reflected across the xz-plane.

Returns:

  • combined_mesh (mesh.Mesh) – A single mesh.Mesh object containing all the transformed and optionally reflected objects.

  • Methods Called

  • ————–

  • transform(t) – Applies transformations to the objects in the scene at the given time step t.

  • copy.deepcopy() – Creates a copy of each object for applying reflections.

transform(t)[source]#

Apply transformations to all sprite objects in the scene at the given time step.

This method iterates through all Sprite objects in the scene and applies the corresponding transformations based on the provided time step t. If the time step is negative, it returns the original mesh for each sprite. Otherwise, it applies the transformation based on the current time step and returns the transformed meshes.

Parameters:

t (float) – The time step used to determine which transformation (original or transformed) to apply to the sprite objects in the scene.

Returns:

  • transformed_objects (list of mesh.Mesh) – A list of transformed meshes corresponding to each sprite object in the scene.

  • Methods Called

  • ————–

  • spr.transform() – Transforms each sprite in the scene at the given time step t.

class src.core.core.Sprite(object_: Object3D, positions: array, angles: array)[source]#

Bases: object

Sprite Class#

A class representing a 3D sprite object that can be transformed over time based on its positions and angles.

This class uses an Object3D instance to represent the sprite and applies transformations (translation and rotation) over time. The sprite’s position and rotation are stored for each time step and can be used to compute its transformation.

object_#

The 3D object that represents the sprite.

Type:

Object3D

positions#

An array of 3D positions (x, y, z) at different time steps.

Type:

np.array of shape (n, 3)

angles#

An array of rotation angles (alpha, beta, gamma) at different time steps.

Type:

np.array of shape (n, 3)

frame_origin#

The origin of the sprite’s local frame of reference (default is [0, 0, 0]).

Type:

list of length 3

frame_orientation#

The orientation of the sprite’s local frame of reference (default is [0, 0, 0]).

Type:

list of length 3

__init__(object_, positions, angles):

Initializes the sprite object with a 3D object, position and angle arrays.

transform(t):

Transforms the sprite based on its position and rotation at the given time step t.

transform(t)[source]#

Apply the transformation to the sprite at the given time step.

This method transforms the sprite using the stored positions and angles for the given time step t. It calls the transform method of the Object3D instance to apply translation, rotation, and any other transformations.

Parameters:

t (int) – The time step index used to select the position and angles for transformation.

Returns:

  • mesh.Mesh – The transformed mesh object after applying the transformations for the specified time step.

  • Methods Called

  • ————–

  • object_.transform() – Applies the position and rotation transformations based on the stored position and angles.

Module contents#