Helper functions


resolution_conversion(resolution)

Converts the given resolution so that there are odd number of points along each axis.

Parameters:
  • resolution (int) –

    Given resolution along an axis.

Returns:
  • int

    converted Resolution along an axis.

generate_grid(size, resolution)

Generates a grid of points based on the provided size and resolution, centered at zero. The dimensionality of the grid is determined from the number of elements in the size input parameter.

Parameters:
  • size (int | float | tuple | list | ndarray) –

    size of the grid along each dimension.

  • resolution (int | tuple | list | ndarray) –

    number of grid points along each dimension.

Returns:
  • (ndarray, tuple)

    Point cloud of points with shape (D, N), where D - dimensionality, N - total number of points in the grid.,

  • (ndarray, tuple)

    Converted resolution of the grid, containing the number of points along each axis.

smarter_reshape(pattern, resolution)

Converts the Signed Distance field point cloud into a grid.

Parameters:
  • pattern (ndarray) –

    Signed Distance field

  • resolution (tuple | list | ndarray) –

    Resolution of the grid, determining the number of points along each axis.

Returns:
  • ndarray

    Signed distance field in a grid.

vector_smarter_reshape(pattern, resolution)

Converts a vector field point cloud into a grid.

Parameters:
  • pattern (ndarray) –

    Vector field

  • resolution (tuple | list | ndarray) –

    Resolution of the grid, determining the number of points along each axis.

Returns:
  • ndarray

    Vector field on a grid of shape (3, resolution[0], resolution[1], resolution[2]).

nd_vector_smarter_reshape(pattern, resolution)

Converts an n-dimensional vector field point cloud into a grid.

Parameters:
  • pattern (ndarray) –

    Vector field

  • resolution (tuple | list | ndarray) –

    Resolution of the grid, determining the number of points along each axis.

Returns:
  • ndarray

    Vector field on a grid of shape (ND, resolution[0], resolution[1], resolution[2]).

binning(pattern, bins, equal_width=True)

Discretize the Signed Distance field/pattern to based on the specified number of bins.

Parameters:
  • pattern (ndarray) –

    Signed Distance field or any field.

  • bins (int) –

    Number of bins - unique discrete values in the final pattern.

  • equal_width (bool, default: True ) –

    All the bins are of equal width. If False the first and the last bin have half the width.

Returns:
  • ndarray

    Modified field.