23#ifndef VCL_ALGORITHMS_CORE_DISTANCE_ELEMENT_H
24#define VCL_ALGORITHMS_CORE_DISTANCE_ELEMENT_H
28#include <vclib/algorithms/core/bounding_box.h>
29#include <vclib/algorithms/core/polygon.h>
30#include <vclib/concepts/mesh.h>
31#include <vclib/math/min_max.h>
32#include <vclib/space/core/triangle_wrapper.h>
49template<VertexConcept VertexType, Po
int3Concept Po
intType>
50auto distance(
const VertexType& v,
const PointType&
p)
52 return v.coord().dist(
p);
60template<Po
int3Concept Po
intType, VertexConcept VertexType>
61auto distance(
const PointType&
p,
const VertexType& v)
63 return v.coord().dist(
p);
80template<VertexConcept VertexType1, VertexConcept VertexType2>
83 return v1.coord().dist(v2.coord());
109template<Po
int3Concept Po
intType, FaceConcept FaceType,
typename ScalarType>
119 f.vertex(0)->coord(), f.vertex(1)->coord(), f.vertex(2)->coord());
124 if (f.vertexNumber() == 3) {
126 f.vertex(0)->coord(),
127 f.vertex(1)->coord(),
128 f.vertex(2)->coord());
133 ScalarType minDist = maxDist;
136 for (uint
i = 0;
i <
tris.size();
i += 3) {
141 f.vertex(
tris[
i])->coord(),
142 f.vertex(
tris[
i + 1])->coord(),
143 f.vertex(
tris[
i + 2])->coord()),
148 if (std::abs(d) < minDist) {
149 minDist = std::abs(d);
180template<Po
int3Concept Po
intType, FaceConcept FaceType,
typename ScalarType>
197template<FaceConcept FaceType, Po
int3Concept Po
intType,
typename ScalarType>
228template<Po
int3Concept Po
intType, FaceConcept FaceType>
235 using ScalarType = PointType::ScalarType;
237 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
260template<Po
int3Concept Po
intType, FaceConcept FaceType>
263 using ScalarType = PointType::ScalarType;
267 ScalarType maxDist = std::numeric_limits<ScalarType>::max();
276template<FaceConcept FaceType, Po
int3Concept Po
intType>
301template<VertexConcept VertexType, FaceConcept FaceType>
312template<FaceConcept FaceType, VertexConcept VertexType>
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The TriangleWrapper class is a wrapper around a N-Dimensional triangle.
Definition triangle_wrapper.h:54
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
std::vector< uint > earCut(Iterator begin, Iterator end)
Triangulates a simple polygon with no holes using the ear-cutting algorithm.
Definition ear_cut.h:92