23#ifndef VCL_ALGORITHMS_CORE_DISTANCE_DISTANCE_H
24#define VCL_ALGORITHMS_CORE_DISTANCE_DISTANCE_H
26#include <vclib/algorithms/core/bounding_box.h>
28#include <vclib/space/core.h>
44template<Po
intConcept Po
intType>
45auto distance(
const PointType& point0,
const PointType& point1)
47 return point0.dist(point1);
67template<Po
int3Concept Po
intType, PlaneConcept PlaneType>
69 const PointType& point,
73 auto dist =
plane.direction().dot(point) -
plane.offset();
75 dist = std::abs(dist);
84template<PlaneConcept PlaneType, Po
int3Concept Po
intType>
87 const PointType& point,
110template<Po
intConcept Po
intType, SegmentConcept SegmentType>
112 const PointType& point,
114 PointType&
closestPoint)
requires (PointType::DIM == SegmentType::DIM)
116 using ScalarType = PointType::ScalarType;
121 ScalarType
esn =
dir.squaredNorm();
123 if (
esn < std::numeric_limits<ScalarType>::min()) {
153template<Po
intConcept Po
intType, SegmentConcept SegmentType>
155 requires (PointType::DIM == SegmentType::DIM)
166template<SegmentConcept SegmentType, Po
intConcept Po
intType>
168 requires (PointType::DIM == SegmentType::DIM)
200 Point3Concept PointType,
201 Triangle3Concept TriangleType,
221 if (
triangle.normal().norm() == 0) {
244 if (std::abs(dist) >= maxDist)
245 return std::abs(dist);
302 const ScalarType
EPS = ScalarType(0.000001);
318 dist = std::abs(dist);
342 Point3Concept PointType,
343 Triangle3Concept TriangleType,
371 Point3Concept PointType,
372 Triangle3Concept TriangleType,
380 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
399 Point3Concept PointType,
400 Triangle3Concept TriangleType,
409 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
419 Triangle3Concept TriangleType,
420 Point3Concept PointType,
A class representing a box in N-dimensional space.
Definition box.h:46
auto diagonal() const
Calculates the diagonal length of the box.
Definition box.h:246
PointT & max()
Returns a reference to the maximum point of the box.
Definition box.h:104
PointT & min()
Returns a reference to the minimum point of the box.
Definition box.h:90
constexpr auto min(const T &p1, const T &p2)
Returns the minimum between the two parameters.
Definition min_max.h:40
auto boundingBox(const PointType &p)
Compute the bounding box of a single point.
Definition bounding_box.h:59
auto 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.
Definition distance.h:203
auto distance(const PointType &point0, const PointType &point1)
Compute the distance between two Points of any dimension.
Definition distance.h:45