src.core package#
Subpackages#
- src.core.inverse_kinematics package
- src.core.transforms package
- Submodules
- src.core.transforms.euler_angles module
Rx()Ry()Rz()rotation_matrix_x_y_x()rotation_matrix_x_y_z()rotation_matrix_x_z_x()rotation_matrix_x_z_y()rotation_matrix_y_x_y()rotation_matrix_y_x_z()rotation_matrix_y_z_x()rotation_matrix_y_z_y()rotation_matrix_z_x_y()rotation_matrix_z_x_z()rotation_matrix_z_y_x()rotation_matrix_z_y_z()
- src.core.transforms.flexibility module
- src.core.transforms.functional_flexibility module
- src.core.transforms.rotation module
- src.core.transforms.translation module
- src.core.transforms.vtk_transform module
- Module contents
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:
objectObject3D 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:
- rotation_transform#
The transformation applied to the object for rotation.
- Type:
- flexibility_transform#
The transformation applied to the object for flexibility (deformation).
- Type:
- __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:
objectScene 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.
- __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:
objectSprite 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.
- 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.