MUDA
Loading...
Searching...
No Matches
distance_type.h
1#pragma once
2#include <muda/muda_def.h>
3#include <muda/tools/debug_log.h>
4#include <muda/ext/eigen/eigen_core_cxx20.h>
5#include <Eigen/Geometry>
6
7namespace muda::distance
8{
9enum class PointPointDistanceType : unsigned char
10{
11 PP = 0, // point-point, the shortest distance is the distance between the two points
12};
13
14enum class PointEdgeDistanceType : unsigned char
15{
16 PP_PE0 = 0, // point-edge, the shortest distance is the distance between the point and the point 0 in edge
17 PP_PE1 = 1, // point-edge, the shortest distance is the distance between the point and the point 1 in edge
18 PE = 2, // point-edge, the shortest distance is the distance between the point and some point on the edge
19};
20
21enum class PointTriangleDistanceType : unsigned char
22{
23 PP_PT0 = 0, // point-triangle, the closest point is the point 0 in triangle
24 PP_PT1 = 1, // point-triangle, the closest point is the point 1 in triangle
25 PP_PT2 = 2, // point-triangle, the closest point is the point 2 in triangle
26 PE_PT0T1 = 3, // point-triangle, the closest point is on the edge (t0, t1)
27 PE_PT1T2 = 4, // point-triangle, the closest point is on the edge (t1, t2)
28 PE_PT2T0 = 5, // point-triangle, the closest point is on the edge (t2, t0)
29 PT = 6, // point-triangle, the closest point is on the triangle
30};
31
32enum class EdgeEdgeDistanceType : unsigned char
33{
34 PP_Ea0Eb0 = 0, // point-point, the shortest distance is the distance between the point 0 in edge a and the point 0 in edge b
35 PP_Ea0Eb1 = 1, // point-point, the shortest distance is the distance between the point 0 in edge a and the point 1 in edge b
36 PE_Ea0Eb0Eb1 = 2, // point-edge, the shortest distance is the distance between the point 0 in edge a and some point the edge b
37 PP_Ea1Eb0 = 3, // point-point, the shortest distance is the distance between the point 1 in edge a and the point 0 in edge b
38 PP_Ea1Eb1 = 4, // point-point, the shortest distance is the distance between the point 1 in edge a and the point 1 in edge b
39 PE_Ea1Eb0Eb1 = 5, // point-edge, the shortest distance is the distance between the point 1 in edge a and some point the edge b
40 PE_Eb0Ea0Ea1 = 6, // point-edge, the shortest distance is the distance between the point 0 in edge b and some point the edge a
41 PE_Eb1Ea0Ea1 = 7, // point-edge, the shortest distance is the distance between the point 1 in edge b and some point the edge a
42 EE = 8, // edge-edge, the shortest distance is the distance between some point on edge a and some point on edge b
43};
44
45
46template <class T, int dim>
47MUDA_GENERIC PointPointDistanceType point_point_distance_type(
48 const Eigen::Vector<T, dim>& p0, const Eigen::Vector<T, dim>& p1);
49
50template <class T, int dim>
51MUDA_GENERIC PointEdgeDistanceType
52point_edge_distance_type(const Eigen::Vector<T, dim>& p,
53 const Eigen::Vector<T, dim>& e0,
54 const Eigen::Vector<T, dim>& e1);
55
56template <class T, int dim>
57MUDA_GENERIC PointEdgeDistanceType
58point_edge_distance_type(const Eigen::Vector<T, dim>& p,
59 const Eigen::Vector<T, dim>& e0,
60 const Eigen::Vector<T, dim>& e1,
61 T& ratio);
62
63template <class T>
64MUDA_GENERIC PointTriangleDistanceType
65point_triangle_distance_type(const Eigen::Vector<T, 3>& p,
66 const Eigen::Vector<T, 3>& t0,
67 const Eigen::Vector<T, 3>& t1,
68 const Eigen::Vector<T, 3>& t2);
69
70// a more robust implementation of http://geomalgorithms.com/a07-_distance.html
71template <class T>
72MUDA_GENERIC EdgeEdgeDistanceType edge_edge_distance_type(const Eigen::Vector<T, 3>& ea0,
73 const Eigen::Vector<T, 3>& ea1,
74 const Eigen::Vector<T, 3>& eb0,
75 const Eigen::Vector<T, 3>& eb1);
76
77} // namespace muda::distance
78
79#include "details/distance_type.inl"