23#ifndef VCL_ALGORITHMS_CORE_DISTANCE_MISC_H
24#define VCL_ALGORITHMS_CORE_DISTANCE_MISC_H
26#include <vclib/algorithms/core/bounding_box.h>
27#include <vclib/concepts/space/triangle.h>
28#include <vclib/space/core/plane.h>
29#include <vclib/space/core/segment.h>
45template<Po
intConcept Po
intType>
46auto distance(
const PointType& point0,
const PointType& point1)
48 return point0.dist(point1);
68template<Po
int3Concept Po
intType, PlaneConcept PlaneType>
70 const PointType& point,
74 auto dist =
plane.direction().dot(point) -
plane.offset();
76 dist = std::abs(dist);
85template<PlaneConcept PlaneType, Po
int3Concept Po
intType>
88 const PointType& point,
111template<Po
intConcept Po
intType, SegmentConcept SegmentType>
113 const PointType& point,
115 PointType&
closestPoint)
requires (PointType::DIM == SegmentType::DIM)
117 using ScalarType = PointType::ScalarType;
122 ScalarType
esn =
dir.squaredNorm();
124 if (
esn < std::numeric_limits<ScalarType>::min()) {
154template<Po
intConcept Po
intType, SegmentConcept SegmentType>
156 requires (PointType::DIM == SegmentType::DIM)
167template<SegmentConcept SegmentType, Po
intConcept Po
intType>
169 requires (PointType::DIM == SegmentType::DIM)
201 Point3Concept PointType,
202 Triangle3Concept TriangleType,
222 if (
triangle.normal().norm() == 0) {
228 if (
box.diagonal() > 0) {
245 if (std::abs(dist) >= maxDist)
246 return std::abs(dist);
303 const ScalarType
EPS = ScalarType(0.000001);
319 dist = std::abs(dist);
343 Point3Concept PointType,
344 Triangle3Concept TriangleType,
372 Point3Concept PointType,
373 Triangle3Concept TriangleType,
381 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
400 Point3Concept PointType,
401 Triangle3Concept TriangleType,
410 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
420 Triangle3Concept TriangleType,
421 Point3Concept PointType,
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
PointT & p0()
Returns the first endpoint of the segment.
Definition segment.h:83
PointT & p1()
Returns the second endpoint of the segment.
Definition segment.h:97
auto boundingBox(const PointType &p)
Compute the bounding box of a single point.
Definition bounding_box.h:65
auto boundedDistance(const PointType &p, const FaceType &f, ScalarType maxDist, PointType &closest, bool signedDist=false)
Compute the distance between a 3D point and a face.
Definition element.h:110
auto distance(const VertexType &v, const PointType &p)
Computes the distance between a Vertex and a 3D point.
Definition element.h:50
constexpr auto min(const T &p1, const T &p2)
Returns the minimum between the two parameters.
Definition min_max.h:42