Distances Computation

From CloudCompareWiki
Jump to: navigation, search

This section describes what kind of distances can be computed with CloudCompare and how these distances are computed.

There's mainly two kinds of distances described below:

  • either the distances between two point clouds (cloud-cloud distances)
  • or the distances between a point cloud and a mesh (cloud-mesh distances)

The third kind of distances that would naturally come to mind - the 'mesh-mesh' distance - will be treated by CloudCompare as a 'cloud-mesh' distance: one can either choose to use only the compared mesh vertices for computing distances (if they are regularly and densely sampled on the surface) or alternatively to sample points on the compared mesh surface. More information can be found in the How to compare two 3D models tutorial.

Cloud-cloud distances

Cloud-cloud distances can be computed by selecting two point clouds and then clicking on the CloudCloudDistanceIcon.png icon.

See the Cloud-to-Cloud Distance computation tool page for more information.

The default way to compute distances between two point cloud is the 'nearest neighbor distance': for each point of the compared cloud, CloudCompare searches the nearest point in the reference cloud and computes their (euclidean) distance. This corresponds to the (default) case where local model is set to 'NONE'.


Local modeling

If the reference point cloud is dense enough, approximating the distance from the compared cloud to the underlying surface represented by the reference cloud is acceptable. But if the reference cloud is not dense enough, the nearest neighbor distance is sometimes not precise enough. Therefore, it can be necessary to get a better model of the surface. Of course, if one can obtain a global model of the surface easily, it's much simpler and potentially more accurate to compute directly the distance from the compared cloud to this model (see the 'Cloud-mesh distances' section below). But it's generally not so easy to get a clean and proper global model. Therefore, CloudCompare provides an intermediate way to get a better approximation of the true distance to the reference surface. Not as precise as a true global model, but much easier to compute.


When CloudCompare has determined the nearest point in the reference cloud, the idea is to locally model the reference cloud (underlying) surface by fitting a mathematical model on the 'nearest' point and several of its neighbors. The distance from each point of the compared cloud to its nearest point in the reference cloud is replaced by the distance to this model. This is statistically more precise and less dependent on the cloud sampling (it can locally produce strange results - as the modelling phase is very limited - but it gives much better results on a global scale).


With the latest version of CloudCompare, the user can fully setup the way the job is done by choosing:

  • the mathematical model: either the least square best fitting plane, or a 2D1/2 Delaunay triangulation, or a quadratic height function (the latter being the more precise but also the longer to compute)
  • the way the neighbors are extracted around each 'nearest' point in the reference cloud (either by setting a fixed number of neighbors, or by providing the radius of a spherical neighborhood)
  • and eventually one can choose to apply an approximation of this scheme by sharing the same local model with several points of the reference cloud instead of computing a new model for each. The process is much faster this way (especially for big neighborhoods) but also much noisier.

Result without (left) and with local modeling (right). Note that the maximum distance doesn't change while the lower part of the histogram is clearly shifted towards zero.

General considerations

When comparing two points clouds directly (especially without model), here are a few 'guidelines':

  • make sure that the reference cloud extents are wider than the compared cloud ones (to avoid virtually high distances on the boundaries). More generally, try to make sure that the reference cloud always overlaps the compared one (that's also true for cloud-mesh distances).
  • always try to get the highest possible density for the reference cloud (as it will directly change the results accuracy)
  • if the reference cloud is very noisy, consider using the least square best fitting plane model (which is more robust to noise). On the contrary, if the reference cloud is clean but with high curvature, consider using the quadratic height function.

Other options

CloudCompare can split the computed distances along the 3 main dimensions (X, Y and Z). If the split X, Y and Z components checkbox is checked, CloudCompare will generate 3 more scalar fields, on for each axis.

Cloud-mesh distances

Cloud-mesh distances can be computed by selecting one point cloud and one mesh and then clicking on the CloudMeshDistanceIcon.png icon.

See the Cloud-to-Mesh Distance computation tool page for more information.


In this mode, for each point of the compared cloud CloudCompare will simply search the nearest triangle in the reference mesh. As meshes generally provide (indirectly) a side information (one can determine what is inside and outside of the mesh by looking at the normal of the triangle), cloud-mesh distances can be signed (this is the default behavior).

The user can choose to either ignore the normal information (by unchecking the 'signed distances' checkbox) or to invert it ('flip normals' checkbox).