Geometry


GenericGeometry

Bases: EuclideanTransform, ModifyObject

Constructs geometry based on an SDF.

Parameters:
  • geo_sdf (Callable[[ndarray, tuple], ndarray]) –

    SDF of a geometry - geo_sdf(co, *geo_parameters).

  • geo_parameters (object, default: () ) –

    Parameters of the SDF.

create(co)

Applies the modifications and transformations (in that order) to the SDF and returns the map of the Signed Distance Field.

Parameters:
  • co (ndarray) –

    Point cloud of coordinates (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

Returns:
  • ndarray

    Signed Distance Field of shape (N,).

propagate(co, *parameters_)

Applies the modifications and transformations (in that order) to the SDF and returns the map of the Signed Distance Field. Similar to create but is meant to be used as input to construct new geometry.

Parameters:
  • co (ndarray) –

    Point cloud of coordinates (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty

Returns:
  • ndarray

    Signed Distance Field of shape (N,).

point_cloud(co)

Creates a point cloud from the interior points of the SDF.

Parameters:
  • co (ndarray) –

    Point cloud of coordinates (D, N);

Points

Bases: EuclideanTransformPoints

Constructs a Points object from a point cloud.

Parameters:
  • points (ndarray | list | tuple) –

    The point cloud of shape (D, N), where D is the spatial dimension and N is the number of points.

cloud: np.ndarray property

Transformed point cloud.

Returns:
  • ndarray

    Transformed point cloud of shape (D, N).

from_image(greyscale_image, image_dimensions, binary_threshold=0.5)

Creates a point cloud from a greyscale image. Positions of the points in the point cloud are calculated from the positions of the pixels with brightness below the binary threshold.

Parameters:
  • greyscale_image (ndarray) –

    The greyscale image.

  • image_dimensions (tuple | list | ndarray) –

    A 2vector defining the size of the image.

  • binary_threshold (float, default: 0.5 ) –

    Threshold used to filter which points belong in the point cloud.

to_image(co_size, co_resolution, extend)

Converts a point cloud into a black and white image. Black where there are points and white where there are none.

Parameters:
  • co_size (tuple | ndarray) –

    Size of the 3D coordinate system (size_x, size_y, size_z).

  • co_resolution (tuple | ndarray) –

    Resolution of the grid along all three dimensions (res_x, res_y, res_z).

  • extend (tuple) –

    Along which directions is the image extended (-X, +X, -Y, +Y, -Z, +Z).

Returns:
  • ndarray

    A grid of voxels with the shape (res_x, res_y, res_z) and values of 0 or 1.

VectorField

Bases: ModifyVectorObject

Constructs a VectorField object from a vector field function.

Parameters:
  • vf (Callable[[ndarray, tuple], ndarray]) –

    The vector field function - vf(p, *vf_parameters).

  • vf_parameters (tuple, default: () ) –

    The parameters of the vector field function.

create(p)

Applies the modifications to the vector field and returns the map of the vector field.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

Returns: Vector field of shape (D, N).

propagate(p, *parameters_)

Applies the modifications to the vector field and returns the map of the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Vector field of shape (D, N).

x(p, *parameters_)

Applies the modifications to the vector field and returns the x component of the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).

y(p, *parameters_)

Applies the modifications to the vector field and returns the x component of the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).

z(p, *parameters_)

Applies the modifications to the vector field and returns the x component of the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).

phi(p, *parameters_)

Applies the modifications and returns the azimuthal angle for each vector in the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).

theta(p, *parameters_)

Applies the modifications and returns the polar angle for each vector in the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).

length(p, *parameters_)

Applies the modifications and returns the lengths of vectors in the vector field. Similar to create but is meant to be used as input to construct new vector fields.

Parameters:
  • p (ndarray) –

    Point cloud of field components (D, N); D - number of dimensions (2,3); N - number of points in the point cloud.

  • parameters_ (tuple, default: () ) –

    can be empty.

Returns:
  • ndarray

    Scalar field of shape (N,).