Custom Deformation¶
Module for a custom deformation.
- class CustomDeformation(func)[source]
Bases:
pygem.deformation.Deformation
Class to perform a custom deformation to the mesh points.
- Parameters
func (callable) – the function definying the deformation of the input points. This function should take as input: i) a 2D array of shape (n_points, 3) in which the points are arranged by row, or ii) an iterable object with 3 components. In this last case, computation of deformation is not vectorized and the overall cost may become heavy.
- Example
>>> from pygem import CustomDeformation >>> import numpy as np >>> def move(x): >>> return x + x**2 >>> deform = CustomDeformation(move) >>> original_mesh_points = np.load( >>> 'tests/test_datasets/meshpoints_sphere_orig.npy') >>> new_mesh_points = deform(original_mesh_points) >>> # Deformation with non-vectorized function >>> def move(x): >>> x0, x1, x2 = x >>> return [x0**2, x1, x2] >>> deform = CustomDeformation(move) >>> new_mesh_points = deform(original_mesh_points)
- __call__(src_pts)[source]
This method performs the deformation on the input points.
- Parameters
src_pts (numpy.ndarray) – the array of dimensions (n_points, 3) containing the points to deform. The points have to be arranged by row.
- Returns
the deformed points
- Return type
numpy.ndarray (with shape = (n_points, 3))