splinepy.bspline.BSpline.proximities#

BSpline.proximities(queries, initial_guess_sample_resolutions=None, tolerance=None, max_iterations=-1, tight_search_bounds=False, nthreads=None, return_verbose=False)#

Given physical coordinate, finds a parametric coordinate that maps to the nearest physical coordinate. Also known as “point inversion”.

Makes initial guess by searching for the nearest points with kd-tree. With initial_guess_sample_resolutions value, physical points will be sampled to plant a kd-tree.

The planted kd-tree is saved in cpp object internally and will re-plant if initial_guess_sample_resolutions are positive. Default behavior is to re-plant the tree each query. If you know that spline doesn’t have any inplace changes, and would like to avoid it, set negative values.

If there’s no tree, this will raise runtime error.

Parameters:
  • queries ((n, dim) array-like)

  • initial_guess_sample_resolutions ((para_dim) array-like) – Default is 2 * control_mesh_resolutions. For complex shapes, we recommend setting large values.

  • tolerance (float) – Convergence criteria. Currently for both distance and residual

  • max_iterations (int) – Default is (para_dim * 20)

  • tight_search_bounds (bool) – Default is False. Set search bound to aabb of direct neighbors from the sample grid.

  • nthreads (int)

  • return_verbose (bool) – If False, returns only parametric coords

Returns:

  • para_coord ((n, para_dim) np.ndarray) – Parametric coordinates

  • phys_coord ((n, dim) np.ndarray) – (only if return_verbose) respective physical coordinates

  • phys_diff ((n, dim) np.ndarray) – (only if return_verbose) respective cartesian difference to query

  • distance ((n, 1) np.ndarray) – (only if return_verbose) respective 2-norm of difference

  • convergence_norm ((n, 1) np.ndarrray) – (only if return_verbose) Newton residual

  • first_derivatives ((n, para_dim, dim) np.ndarray) – (only if return_verbose) Convergence information

  • second_derivatives ((n, para_dim, para_dim, dim) np.ndarray) – (only if return_verbose) Convergence information