MUDA
Loading...
Searching...
No Matches
ccd.h
1#pragma once
2#include <muda/muda_def.h>
3#include <muda/ext/geo/distance/distance_type.h>
4#include <muda/ext/geo/distance/distance_unclassified.h>
5#include <cmath>
6
7//ref: https://github.com/ipc-sim/Codim-IPC/tree/main/Library/Math/Distance
8namespace muda::distance
9{
10template <typename T, int dim>
11MUDA_GENERIC bool point_edge_cd_broadphase(const Eigen::Matrix<T, dim, 1>& x0,
12 const Eigen::Matrix<T, dim, 1>& x1,
13 const Eigen::Matrix<T, dim, 1>& x2,
14 T dist);
15
16template <typename T>
17MUDA_GENERIC bool point_edge_ccd_broadphase(const Eigen::Matrix<T, 2, 1>& p,
18 const Eigen::Matrix<T, 2, 1>& e0,
19 const Eigen::Matrix<T, 2, 1>& e1,
20 const Eigen::Matrix<T, 2, 1>& dp,
21 const Eigen::Matrix<T, 2, 1>& de0,
22 const Eigen::Matrix<T, 2, 1>& de1,
23 T dist);
24
25template <typename T>
26MUDA_GENERIC bool point_triangle_cd_broadphase(const Eigen::Matrix<T, 3, 1>& p,
27 const Eigen::Matrix<T, 3, 1>& t0,
28 const Eigen::Matrix<T, 3, 1>& t1,
29 const Eigen::Matrix<T, 3, 1>& t2,
30 T dist);
31template <typename T>
32MUDA_GENERIC bool edge_edge_cd_broadphase(const Eigen::Matrix<T, 3, 1>& ea0,
33 const Eigen::Matrix<T, 3, 1>& ea1,
34 const Eigen::Matrix<T, 3, 1>& eb0,
35 const Eigen::Matrix<T, 3, 1>& eb1,
36 T dist);
37
38template <typename T>
39MUDA_GENERIC bool point_triangle_ccd_broadphase(const Eigen::Matrix<T, 3, 1>& p,
40 const Eigen::Matrix<T, 3, 1>& t0,
41 const Eigen::Matrix<T, 3, 1>& t1,
42 const Eigen::Matrix<T, 3, 1>& t2,
43 const Eigen::Matrix<T, 3, 1>& dp,
44 const Eigen::Matrix<T, 3, 1>& dt0,
45 const Eigen::Matrix<T, 3, 1>& dt1,
46 const Eigen::Matrix<T, 3, 1>& dt2,
47 T dist);
48
49template <typename T>
50MUDA_GENERIC bool edge_edge_ccd_broadphase(const Eigen::Matrix<T, 3, 1>& ea0,
51 const Eigen::Matrix<T, 3, 1>& ea1,
52 const Eigen::Matrix<T, 3, 1>& eb0,
53 const Eigen::Matrix<T, 3, 1>& eb1,
54 const Eigen::Matrix<T, 3, 1>& dea0,
55 const Eigen::Matrix<T, 3, 1>& dea1,
56 const Eigen::Matrix<T, 3, 1>& deb0,
57 const Eigen::Matrix<T, 3, 1>& deb1,
58 T dist);
59
60template <typename T>
61MUDA_GENERIC bool point_edge_ccd_broadphase(const Eigen::Matrix<T, 3, 1>& p,
62 const Eigen::Matrix<T, 3, 1>& e0,
63 const Eigen::Matrix<T, 3, 1>& e1,
64 const Eigen::Matrix<T, 3, 1>& dp,
65 const Eigen::Matrix<T, 3, 1>& de0,
66 const Eigen::Matrix<T, 3, 1>& de1,
67 T dist);
68template <typename T>
69MUDA_GENERIC bool point_point_ccd_broadphase(const Eigen::Matrix<T, 3, 1>& p0,
70 const Eigen::Matrix<T, 3, 1>& p1,
71 const Eigen::Matrix<T, 3, 1>& dp0,
72 const Eigen::Matrix<T, 3, 1>& dp1,
73 T dist);
74
75template <typename T>
76MUDA_GENERIC bool point_triangle_ccd(Eigen::Matrix<T, 3, 1> p,
77 Eigen::Matrix<T, 3, 1> t0,
78 Eigen::Matrix<T, 3, 1> t1,
79 Eigen::Matrix<T, 3, 1> t2,
80 Eigen::Matrix<T, 3, 1> dp,
81 Eigen::Matrix<T, 3, 1> dt0,
82 Eigen::Matrix<T, 3, 1> dt1,
83 Eigen::Matrix<T, 3, 1> dt2,
84 T eta,
85 T thickness,
86 int max_iter,
87 T& toc);
88
89template <typename T>
90MUDA_GENERIC bool edge_edge_ccd(Eigen::Matrix<T, 3, 1> ea0,
91 Eigen::Matrix<T, 3, 1> ea1,
92 Eigen::Matrix<T, 3, 1> eb0,
93 Eigen::Matrix<T, 3, 1> eb1,
94 Eigen::Matrix<T, 3, 1> dea0,
95 Eigen::Matrix<T, 3, 1> dea1,
96 Eigen::Matrix<T, 3, 1> deb0,
97 Eigen::Matrix<T, 3, 1> deb1,
98 T eta,
99 T thickness,
100 int max_iter,
101 T& toc);
102
103template <typename T>
104MUDA_GENERIC bool point_edge_ccd(const Eigen::Matrix<T, 2, 1>& x0,
105 const Eigen::Matrix<T, 2, 1>& x1,
106 const Eigen::Matrix<T, 2, 1>& x2,
107 const Eigen::Matrix<T, 2, 1>& d0,
108 const Eigen::Matrix<T, 2, 1>& d1,
109 const Eigen::Matrix<T, 2, 1>& d2,
110 T eta,
111 T& toc);
112
113template <typename T>
114MUDA_GENERIC bool point_edge_ccd(Eigen::Matrix<T, 3, 1> p,
115 Eigen::Matrix<T, 3, 1> e0,
116 Eigen::Matrix<T, 3, 1> e1,
117 Eigen::Matrix<T, 3, 1> dp,
118 Eigen::Matrix<T, 3, 1> de0,
119 Eigen::Matrix<T, 3, 1> de1,
120 T eta,
121 T thickness,
122 int max_iter,
123 T& toc);
124template <typename T>
125MUDA_GENERIC bool point_point_ccd(Eigen::Matrix<T, 3, 1> p0,
126 Eigen::Matrix<T, 3, 1> p1,
127 Eigen::Matrix<T, 3, 1> dp0,
128 Eigen::Matrix<T, 3, 1> dp1,
129 T eta,
130 T thickness,
131 int max_iter,
132 T& toc);
133} // namespace muda
134
135#include "details/ccd.inl"