Visual Computing Library
Loading...
Searching...
No Matches
Core Distance Algorithms

List of distance algorithms. More...

Collaboration diagram for Core Distance Algorithms:

Functions

template<VertexConcept VertexType, Point3Concept PointType>
auto vcl::distance (const VertexType &v, const PointType &p)
 Computes the distance between a Vertex and a 3D point.
 
template<Point3Concept PointType, VertexConcept VertexType>
auto vcl::distance (const PointType &p, const VertexType &v)
 Computes the distance between a Vertex and a 3D point.
 
template<VertexConcept VertexType1, VertexConcept VertexType2>
auto vcl::distance (const VertexType1 &v1, const VertexType2 &v2)
 Computes the distance between two vertices.
 
template<Point3Concept PointType, FaceConcept FaceType, typename ScalarType >
auto vcl::boundedDistance (const PointType &p, const FaceType &f, ScalarType maxDist, PointType &closest, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<Point3Concept PointType, FaceConcept FaceType, typename ScalarType >
auto vcl::boundedDistance (const PointType &p, const FaceType &f, ScalarType maxDist, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<FaceConcept FaceType, Point3Concept PointType, typename ScalarType >
auto vcl::boundedDistance (const FaceType &f, const PointType &p, ScalarType maxDist, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<Point3Concept PointType, FaceConcept FaceType>
auto vcl::distance (const PointType &p, const FaceType &f, PointType &closest, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<Point3Concept PointType, FaceConcept FaceType>
auto vcl::distance (const PointType &p, const FaceType &f, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<FaceConcept FaceType, Point3Concept PointType>
auto vcl::distance (const FaceType &f, const PointType &p, bool signedDist=false)
 Compute the distance between a 3D point and a face.
 
template<VertexConcept VertexType, FaceConcept FaceType>
auto vcl::distance (const VertexType &v, const FaceType &f, bool signedDist=false)
 Compute the distance between a vertex and a face.
 
template<FaceConcept FaceType, VertexConcept VertexType>
auto vcl::distance (const FaceType &f, const VertexType &v, bool signedDist=false)
 Compute the distance between a vertex and a face.
 
template<typename Obj1 , typename Obj2 >
auto vcl::distFunction ()
 Return a proper dist function between a Obj1 object and an Obj2 object.
 
template<typename Obj1 , typename Obj2 , typename ScalarType = double>
auto vcl::boundedDistFunction ()
 Return a proper bounded distance function between a Obj1 object and an Obj2 object.
 
template<PointConcept PointType>
auto vcl::distance (const PointType &point0, const PointType &point1)
 Compute the distance between two Points of any dimension.
 
template<Point3Concept PointType, PlaneConcept PlaneType>
auto vcl::distance (const PointType &point, const PlaneType &plane, bool signedDist=false)
 Compute the distance between a point and a plane.
 
template<PlaneConcept PlaneType, Point3Concept PointType>
auto vcl::distance (const PlaneType &plane, const PointType &point, bool signedDist=false)
 Compute the distance between a point and a plane.
 
template<PointConcept PointType, SegmentConcept SegmentType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance (const PointType &point, const SegmentType &segment, PointType &closestPoint)
 Compute the distance between a point and a segment.
 
template<PointConcept PointType, SegmentConcept SegmentType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance (const PointType &point, const SegmentType &segment)
 Compute the distance between a point and a segment.
 
template<SegmentConcept SegmentType, PointConcept PointType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance (const SegmentType &segment, const PointType &point)
 Compute the distance between a point and a segment.
 
template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::boundedDistance (const PointType &p, const TriangleType &triangle, ScalarType maxDist, PointType &closest, bool signedDist=false)
 Compute the bounded distance between a 3D point and a 3D triangle.
 
template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::boundedDistance (const PointType &p, const TriangleType &triangle, ScalarType maxDist, bool signedDist=false)
 Compute the distance between a 3D point and a 3D triangle.
 
template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::distance (const PointType &p, const TriangleType &triangle, PointType &closest, bool signedDist=false)
 Compute the distance between a 3D point and a 3D triangle.
 
template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::distance (const PointType &p, const TriangleType &triangle, bool signedDist=false)
 Compute the distance between a 3D point and a 3D triangle.
 
template<Triangle3Concept TriangleType, Point3Concept PointType, typename ScalarType >
auto vcl::distance (const TriangleType &triangle, const PointType &p, bool signedDist=false)
 Compute the distance between a 3D point and a 3D triangle.
 

Detailed Description

List of distance algorithms.

You can access these algorithms by including #include <vclib/algorithms/core/distance.h>

Function Documentation

◆ boundedDistance() [1/5]

template<FaceConcept FaceType, Point3Concept PointType, typename ScalarType >
auto vcl::boundedDistance ( const FaceType &  f,
const PointType &  p,
ScalarType  maxDist,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]maxDistThe maximum distance to consider. If the distance is greater than this value, the function returns immediately. Default is std::numeric_limits<ScalarType>::max().
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ boundedDistance() [2/5]

template<Point3Concept PointType, FaceConcept FaceType, typename ScalarType >
auto vcl::boundedDistance ( const PointType &  p,
const FaceType &  f,
ScalarType  maxDist,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]maxDistThe maximum distance to consider. If the distance is greater than this value, the function returns immediately. Default is std::numeric_limits<ScalarType>::max().
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ boundedDistance() [3/5]

template<Point3Concept PointType, FaceConcept FaceType, typename ScalarType >
auto vcl::boundedDistance ( const PointType &  p,
const FaceType &  f,
ScalarType  maxDist,
PointType &  closest,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]maxDistThe maximum distance to consider. If the distance is greater than this value, the function returns immediately. Default is std::numeric_limits<ScalarType>::max().
[out]closestThe closest point on the triangle to the given point.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ boundedDistance() [4/5]

template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::boundedDistance ( const PointType &  p,
const TriangleType triangle,
ScalarType  maxDist,
bool  signedDist = false 
)

Compute the distance between a 3D point and a 3D triangle.

Template Parameters
PointTypeThe type of point.
TriangleTypeThe type of triangle.
Parameters
[in]pThe point to calculate the distance from.
[in]triangleThe triangle to calculate the distance to.
[in]maxDistThe maximum distance to consider. If the distance is greater than this value, the function returns immediately. Default is std::numeric_limits<ScalarType>::max().
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the triangle.

◆ boundedDistance() [5/5]

template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::boundedDistance ( const PointType &  p,
const TriangleType triangle,
ScalarType  maxDist,
PointType &  closest,
bool  signedDist = false 
)

Compute the bounded distance between a 3D point and a 3D triangle.

Compute the distance between a 3D point and a 3D triangle. The distance can be signed or unsigned, depending on the value of the signedDist parameter.

The actual distance is computed only if the absolute value of the distance is less than the maxDist parameter. If the distance is greater than maxDist, the function returns immediately, and the returned value is a value greater than maxDist.

Template Parameters
PointTypeThe type of point.
TriangleTypeThe type of triangle.
Parameters
[in]pThe point to calculate the distance from.
[in]triangleThe triangle to calculate the distance to.
[in]maxDistThe (absolute) maximum distance to consider. If the absolute value of the distance is greater than this value, the function returns immediately. Default is std::numeric_limits<ScalarType>::max().
[out]closestThe closest point on the triangle to the given point.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the triangle.

◆ boundedDistFunction()

template<typename Obj1 , typename Obj2 , typename ScalarType = double>
auto vcl::boundedDistFunction ( )

Return a proper bounded distance function between a Obj1 object and an Obj2 object.

The returned function is a lambda function that takes in input two const references of the desired types, a scalar that represents the bound, and returns a scalar that is the distance between the two objects if it is less than the bound. If the distance is greater than the bound, the distance was not computed totally and should be discarded.

This function is different w.r.t. the distFunction because the returned function here takes three arguments: the two objects on which compute the distance, and a scalar that represent the maximum distance that can be returned. This value is used by some distance functions for performance reasons: it allows to avoid several computation if a first distance does already exceed the maximum value.

If the bounded distance function is not defined, the standard distance function will be used, and the bound parameter will be ignored. If the distance function for your types is not defined, you can write your own vcl::boundedDistance (or vcl::distance) overload that defines a proper bounded distance function.

Note
The boundedDistFunction works only for non-pointer types, because generally the overloads of vcl::distance and vcl::boundedDistance do not take pointers as input. This means that you cannot ask for the distance function between a vcl::Point3d and a vcl::Vertex*. If you are working with template types that you don't know if they are pointers or not, you can do the following:
// don't know if T1 and T2 are pointers or non-pointers
// obj1 is of type T1, obj2 is of type T2 (may be pointers or non-pointers)
auto dist = f(dereferencePtr(obj1), dereferencePtr(obj2), maxDist);
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
auto & dereferencePtr(T &&obj)
Utility function that applies the unary operator '*' to the argument only if the object is a pointer,...
Definition pointers.h:95

◆ distance() [1/17]

template<FaceConcept FaceType, Point3Concept PointType>
auto vcl::distance ( const FaceType &  f,
const PointType &  p,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ distance() [2/17]

template<FaceConcept FaceType, VertexConcept VertexType>
auto vcl::distance ( const FaceType &  f,
const VertexType &  v,
bool  signedDist = false 
)

Compute the distance between a vertex and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
VertexTypeThe type of Vertex. Must satisfy the VertexConcept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]vThe vertex to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the vertex and the face.

◆ distance() [3/17]

template<PlaneConcept PlaneType, Point3Concept PointType>
auto vcl::distance ( const PlaneType plane,
const PointType &  point,
bool  signedDist = false 
)

Compute the distance between a point and a plane.

Compute the distance between a point and a plane. The distance can be signed or unsigned, depending on the value of the signedDist parameter.

Template Parameters
PointTypeThe type of the input point.
PlaneTypeThe type of the input plane.
Parameters
[in]pointThe input point.
[in]planeThe input plane.
[in]signedDistIf true, the distance is signed, otherwise it is unsigned.
Returns
The distance between the point and the plane.

◆ distance() [4/17]

template<Point3Concept PointType, FaceConcept FaceType>
auto vcl::distance ( const PointType &  p,
const FaceType &  f,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ distance() [5/17]

template<Point3Concept PointType, FaceConcept FaceType>
auto vcl::distance ( const PointType &  p,
const FaceType &  f,
PointType &  closest,
bool  signedDist = false 
)

Compute the distance between a 3D point and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
PointTypeThe type of point. Must satisfy the Point3Concept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]pThe point to calculate the distance from.
[in]fThe face to calculate the distance to.
[out]closestThe closest point on the triangle to the given point.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the face.

◆ distance() [6/17]

template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::distance ( const PointType &  p,
const TriangleType triangle,
bool  signedDist = false 
)

Compute the distance between a 3D point and a 3D triangle.

Template Parameters
PointTypeThe type of point.
TriangleTypeThe type of triangle.
Parameters
[in]pThe point to calculate the distance from.
[in]triangleThe triangle to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the triangle.

◆ distance() [7/17]

template<Point3Concept PointType, Triangle3Concept TriangleType, typename ScalarType >
auto vcl::distance ( const PointType &  p,
const TriangleType triangle,
PointType &  closest,
bool  signedDist = false 
)

Compute the distance between a 3D point and a 3D triangle.

Template Parameters
PointTypeThe type of point.
TriangleTypeThe type of triangle.
Parameters
[in]pThe point to calculate the distance from.
[in]triangleThe triangle to calculate the distance to.
[out]closestThe closest point on the triangle to the given point.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the triangle.

◆ distance() [8/17]

template<Point3Concept PointType, VertexConcept VertexType>
auto vcl::distance ( const PointType &  p,
const VertexType &  v 
)

Computes the distance between a Vertex and a 3D point.

Template Parameters
VertexTypeThe type of vertex. Must satisfy the VertexConcept.
PointTypeThe type of point. Must satisfy the Point3Concept.
Parameters
[in]vThe vertex to calculate the distance from.
[in]pThe point to calculate the distance to.
Returns
The distance between the vertex and the point.

◆ distance() [9/17]

template<Point3Concept PointType, PlaneConcept PlaneType>
auto vcl::distance ( const PointType &  point,
const PlaneType plane,
bool  signedDist = false 
)

Compute the distance between a point and a plane.

Compute the distance between a point and a plane. The distance can be signed or unsigned, depending on the value of the signedDist parameter.

Template Parameters
PointTypeThe type of the input point.
PlaneTypeThe type of the input plane.
Parameters
[in]pointThe input point.
[in]planeThe input plane.
[in]signedDistIf true, the distance is signed, otherwise it is unsigned.
Returns
The distance between the point and the plane.

◆ distance() [10/17]

template<PointConcept PointType, SegmentConcept SegmentType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance ( const PointType &  point,
const SegmentType segment 
)

Compute the distance between a point and a segment.

Compute the distance between a point and a segment of any dimension.

Template Parameters
PointTypeThe type of the input point.
SegmentTypeThe type of the input segment.
Parameters
[in]pointThe input point.
[in]segmentThe input segment.
Returns
The distance between the point and the segment.

◆ distance() [11/17]

template<PointConcept PointType, SegmentConcept SegmentType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance ( const PointType &  point,
const SegmentType segment,
PointType &  closestPoint 
)

Compute the distance between a point and a segment.

Compute the distance between a point and a segment of any dimension. The closest point on the segment is also computed, and stored in the closestPoint parameter.

Template Parameters
PointTypeThe type of the input point.
SegmentTypeThe type of the input segment.
Parameters
[in]pointThe input point.
[in]segmentThe input segment.
[out]closestPointThe closest point on the segment.
Returns
The distance between the point and the segment.

◆ distance() [12/17]

template<PointConcept PointType>
auto vcl::distance ( const PointType &  point0,
const PointType &  point1 
)

Compute the distance between two Points of any dimension.

Template Parameters
PointTypeThe type of the input points.
Parameters
[in]point0The first input point.
[in]point1The second input point.
Returns
The distance between the two points.

◆ distance() [13/17]

template<SegmentConcept SegmentType, PointConcept PointType>
requires (PointType::DIM == SegmentType::DIM)
auto vcl::distance ( const SegmentType segment,
const PointType &  point 
)

Compute the distance between a point and a segment.

Compute the distance between a point and a segment of any dimension.

Template Parameters
PointTypeThe type of the input point.
SegmentTypeThe type of the input segment.
Parameters
[in]pointThe input point.
[in]segmentThe input segment.
Returns
The distance between the point and the segment.

◆ distance() [14/17]

template<Triangle3Concept TriangleType, Point3Concept PointType, typename ScalarType >
auto vcl::distance ( const TriangleType triangle,
const PointType &  p,
bool  signedDist = false 
)

Compute the distance between a 3D point and a 3D triangle.

Template Parameters
PointTypeThe type of point.
TriangleTypeThe type of triangle.
Parameters
[in]pThe point to calculate the distance from.
[in]triangleThe triangle to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the point and the triangle.

◆ distance() [15/17]

template<VertexConcept VertexType, FaceConcept FaceType>
auto vcl::distance ( const VertexType &  v,
const FaceType &  f,
bool  signedDist = false 
)

Compute the distance between a vertex and a face.

If the face is a triangle, the function will use the bounded distance function between a point and a triangle. If the face is a polygon, the face is first triangulated using an earcut algorithm, and then for each triangle, the distance between the point and the triangle is computed.

Template Parameters
VertexTypeThe type of Vertex. Must satisfy the VertexConcept.
FaceTypeThe type of face. Must satisfy the FaceConcept.
Parameters
[in]vThe vertex to calculate the distance from.
[in]fThe face to calculate the distance to.
[in]signedDistWhether to calculate the signed distance. Default is false.
Returns
The distance between the vertex and the face.

◆ distance() [16/17]

template<VertexConcept VertexType, Point3Concept PointType>
auto vcl::distance ( const VertexType &  v,
const PointType &  p 
)

Computes the distance between a Vertex and a 3D point.

Template Parameters
VertexTypeThe type of vertex. Must satisfy the VertexConcept.
PointTypeThe type of point. Must satisfy the Point3Concept.
Parameters
[in]vThe vertex to calculate the distance from.
[in]pThe point to calculate the distance to.
Returns
The distance between the vertex and the point.

◆ distance() [17/17]

template<VertexConcept VertexType1, VertexConcept VertexType2>
auto vcl::distance ( const VertexType1 v1,
const VertexType2 v2 
)

Computes the distance between two vertices.

Template Parameters
VertexType1The type of the first vertex. Must satisfy the VertexConcept.
VertexType2The type of the second vertex. Must satisfy the VertexConcept.
Parameters
[in]v1The first vertex.
[in]v2The second vertex.
Returns
The distance between the two vertices.

◆ distFunction()

template<typename Obj1 , typename Obj2 >
auto vcl::distFunction ( )

Return a proper dist function between a Obj1 object and an Obj2 object.

The returned function is a lambda function that takes in input two const references of the desired types and returns a scalar that is the distance between the two objects.

If the distance function for your types is not defined, you can write your own vcl::distance overload that defines a proper distance function.

Note
The distFunction works only for non-pointer types, because generally the overloads of vcl::distance do not take pointers as input. This means that you cannot ask for the distance function between a vcl::Point3d and a vcl::Vertex*. If you are working with template types that you don't know if they are pointers or not, you can do the following:
// don't know if T1 and T2 are pointers or non-pointers
// obj1 is of type T1, obj2 is of type T2 (may be pointers or non-pointers)