pysdic.PointCloud.all_close#
- PointCloud.all_close(other, rtol=1e-05, atol=1e-08, equal_nan=True, ordered=True)[source]#
Check if all points in the current point cloud are approximately equal to the points in another
PointCloudinstance within a tolerance.This method compares the points of the current point cloud with those of another
PointCloudinstance and returns True if all corresponding points are approximately equal within the specified relative and absolute tolerances.Note
If the number of points in both point clouds differ, the method will return False.
See also
numpy.allclose()for more details on the comparison.
- Parameters:
other (Union[
PointCloud, ArrayLike]) – AnotherPointCloudinstance or a NumPy array with shape \((N_p, 3)\) to compare with the current point cloud.rtol (Real, optional) – The relative tolerance parameter (default is
1e-05).atol (Real, optional) – The absolute tolerance parameter (default is
1e-08).equal_nan (
bool, optional) – If True, NaN values are considered equal (default isTrue).ordered (
bool, optional) – If True, the points are compared in order. If False, the points are compared without considering the order (default isTrue).
- Returns:
True if all points are approximately equal within the specified tolerances, False otherwise.
- Return type:
- Raises:
ValueError – If the input is not an instance of
PointCloud.
Examples
Creating a
PointCloudobject 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_cloud1 = PointCloud.from_array(random_points)
Compare the point cloud with another point cloud that is slightly modified.
1# Create a second point cloud by adding small noise to the first one 2noise = np.random.normal(scale=1e-8, size=random_points.shape) 3point_cloud2 = PointCloud.from_array(random_points + noise) 4 5# Check if the two point clouds are approximately equal 6are_close = point_cloud1.all_close(point_cloud2, rtol=1e-5, atol=1e-8) 7print(are_close) 8# Output: True (most likely, depending on the noise)
Compare with a point cloud that is significantly different.
1# Create a third point cloud that is significantly different 2different_points = np.random.rand(100, 3) + 1.0 # Shifted by 1.0 3point_cloud3 = PointCloud.from_array(different_points) 4are_close = point_cloud1.all_close(point_cloud3, rtol=1e-5, atol=1e-8) 5print(are_close) 6# Output: False