API – fitting¶
HOMER.fitting.point_cloud_fit(mesh, data, normals=None, res=20, compile=True, surface_only=False, sob_weight=0.01)
¶
Build a point-cloud fitting cost function and its sparse Jacobian.
Constructs a residual function suitable for scipy.optimize.least_squares
that measures the distance from the mesh surface to the target point cloud,
with an optional Sobolev smoothness regularisation term.
A KD-tree is built from data (and normals when provided) at construction time. Every evaluation then queries this tree against the current mesh surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh
|
The :class: |
required |
data
|
Target point cloud, shape |
required | |
normals
|
Optional surface normals at each target point, shape |
None
|
|
res
|
Number of xi grid points per direction used to sample the mesh surface. |
20
|
|
compile
|
When |
True
|
|
surface_only
|
When |
False
|
|
sob_weight
|
Scalar weight applied to the Sobolev smoothness term. Increase to produce smoother fits at the cost of surface accuracy. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
fitting_function |
Callable
|
Residual function |
jacobian_fun |
Callable
|
Sparse Jacobian function |
Examples:
::
fitting_fn, jac_fn = point_cloud_fit(mesh, target_pts, compile=True)
result = least_squares(fitting_fn, mesh.optimisable_param_array,
jac=jac_fn, verbose=2)
mesh.update_from_params(result.x)