coords.Coords.deform_to#

Coords.deform_to(target, levels=(((3, 3, 3), 0.001, 2), ((4, 4, 4), 0.001, 5)), return_deformation=False, verbose=False)#

Deform coordinates to match a target surface mesh using multi-level FFD.

This method fits a free-form deformation (FFD) to progressively deform this mesh towards the target mesh. The fitting uses an iterative closest point (ICP) approach: at each iteration, closest-point correspondences are computed on the target surface and the FFD control points are optimized while keeping the correspondences fixed.

The target mesh must be a triangular surface mesh (tri3), since closest-point projection is performed onto its triangles.

Parameters#

targetMesh (eltype=’tri3’)

Target triangular surface mesh.

levelssequence, optional

Multi-level FFD fitting parameters. Each level is specified as a tuple:

(control_points, regularization, icp_iterations)

where:

  • control_pointstuple of 3 ints

    Number of FFD control points in each spatial direction. Increasing this value allows more local deformation but increases the number of optimization parameters.

  • regularizationfloat

    Weight of the smoothness penalty applied to the FFD control point displacements. Higher values produce smoother deformations and reduce local distortions.

  • icp_iterationsint

    Number of ICP refinement iterations performed at this level.

Levels are processed in sequence, starting with coarse deformations and progressively allowing finer adjustments.

Default:

(((3, 3, 3), 1e-3, 2), ((4, 4, 4), 1e-3, 5))

return_deformationbool, optional

If True, also return the fitted FFD deformation object. Default is False.

verbosebool, optional

If True, print optimization progress information. Default is False.

Returns#

Coords object

The coordinates after applying the estimated deformation.

(Coords, Deformation) tuple, optional

If return_deformation=True, returns the deformed coordinates together with the fitted deformation object.

Examples#

>>> from hellotriangle import shapes
>>> source = shapes.sphere().coords
>>> target = shapes.sphere().scale([1.2, 1.0, 0.8])
>>> result = source.deform_to(target, levels=(((4, 4, 4), 1e-3, 1),))
>>> result.shape == source.shape
True