MeVisLab Toolbox Reference
ml::LargestPointDistance2D Namespace Reference

Functions

MLPOINTCLOUDUTILS_EXPORT double largestDistanceSquared (const std::vector< Vector2 > &points, Vector2 &point0, Vector2 &point1)
 Calculates the largest distance (squared) between any of the given points. More...
 
MLPOINTCLOUDUTILS_EXPORT double largestDistanceSquaredFromSortedPoints (const std::vector< Vector2 > &points, Vector2 &point0, Vector2 &point1)
 Calculates the largest distance (squared) between any of the given points. More...
 

Function Documentation

◆ largestDistanceSquared()

MLPOINTCLOUDUTILS_EXPORT double ml::LargestPointDistance2D::largestDistanceSquared ( const std::vector< Vector2 > &  points,
Vector2 point0,
Vector2 point1 
)

Calculates the largest distance (squared) between any of the given points.

In addition to the result distance, the two points that lead to the largest distance are also provided. This uses the "rotating calipers" algorithm and works in O(N * log(N)) because it needs to sort the points.

◆ largestDistanceSquaredFromSortedPoints()

MLPOINTCLOUDUTILS_EXPORT double ml::LargestPointDistance2D::largestDistanceSquaredFromSortedPoints ( const std::vector< Vector2 > &  points,
Vector2 point0,
Vector2 point1 
)

Calculates the largest distance (squared) between any of the given points.

The given points need to be lexically sorted (see ConvexHull2D::createConvexHullFromSortedPoints()). In addition to the result distance, the two points that lead to the largest distance are also provided. This uses the "rotating calipers" algorithm and works in O(N) because the points are already sorted.