pysdic.PointCloud.from_array#

classmethod PointCloud.from_array(points, copy=False, properties=None)[source]#

Create a PointCloud object from a NumPy array of shape \((N_p, E)\).

See also

  • to_array() method for converting the point cloud back to a NumPy array.

Parameters:
  • points (ArrayLike) – A NumPy array of shape \((N_p, E)\) representing the coordinates of the points.

  • copy (bool, optional) – If True, a copy of the input array is made. Default is False. If the given object is not a type numpy.float64 array, a copy will be made regardless of this parameter.

  • properties (Optional[Dict[str, ArrayLike]], optional) – A dictionary of additional properties to associate with the point cloud. Keys are property names, and values are NumPy arrays of property data of shape \((N_p, A)\)

Returns:

A PointCloud object containing the provided points.

Return type:

PointCloud

Raises:
  • TypeError – If the input points is not a NumPy array. If the properties is not a dictionary.

  • ValueError – If the input array does not have the correct shape \((N_p, E)\). If the properties arrays do not have the correct shape \((N_p, A)\).

Examples

Creating a PointCloud object from a random NumPy array.

1import numpy as np
2from pysdic import PointCloud
3
4# Create a random point cloud with 100 points
5random_points = np.random.rand(100, 3)  # shape (100, 3)
6point_cloud = PointCloud.from_array(random_points)

Now, point_cloud is a PointCloud object containing the points from the NumPy array.