38 #ifndef FCL_BV_KDOP_INL_H 39 #define FCL_BV_KDOP_INL_H 62 void minmax(
double a,
double b,
double& minv,
double& maxv);
66 void minmax(
double p,
double& minv,
double& maxv);
81 template <
typename S, std::
size_t N>
85 static_assert(N == 16 || N == 18 || N == 24,
"N should be 16, 18, or 24");
88 for(std::size_t i = 0; i < N / 2; ++i)
91 dist_[i + N / 2] = -real_max;
96 template <
typename S, std::
size_t N>
100 for(std::size_t i = 0; i < 3; ++i)
102 dist_[i] = dist_[N / 2 + i] = v[i];
107 for(std::size_t i = 0; i < (N - 6) / 2; ++i)
109 dist_[3 + i] = dist_[3 + i + N / 2] = d[i];
114 template <
typename S, std::
size_t N>
118 for(std::size_t i = 0; i < 3; ++i)
120 minmax(a[i], b[i], dist_[i], dist_[i + N / 2]);
123 S ad[(N - 6) / 2], bd[(N - 6) / 2];
126 for(std::size_t i = 0; i < (N - 6) / 2; ++i)
128 minmax(ad[i], bd[i], dist_[3 + i], dist_[3 + i + N / 2]);
133 template <
typename S, std::
size_t N>
137 for(std::size_t i = 0; i < N / 2; ++i)
139 if(dist_[i] > other.
dist_[i + N / 2])
return false;
140 if(dist_[i + N / 2] < other.
dist_[i])
return false;
147 template <
typename S, std::
size_t N>
151 for(std::size_t i = 0; i < 3; ++i)
153 if(p[i] < dist_[i] || p[i] > dist_[i + N / 2])
159 for(std::size_t i = 0; i < (N - 6) / 2; ++i)
161 if(d[i] < dist_[3 + i] || d[i] > dist_[i + 3 + N / 2])
169 template <
typename S, std::
size_t N>
173 for(std::size_t i = 0; i < 3; ++i)
175 minmax(p[i], dist_[i], dist_[N / 2 + i]);
180 for(std::size_t i = 0; i < (N - 6) / 2; ++i)
182 minmax(pd[i], dist_[3 + i], dist_[3 + N / 2 + i]);
189 template <
typename S, std::
size_t N>
193 for(std::size_t i = 0; i < N / 2; ++i)
196 dist_[i + N / 2] =
std::max(other.
dist_[i + N / 2], dist_[i + N / 2]);
202 template <
typename S, std::
size_t N>
211 template <
typename S, std::
size_t N>
215 return dist_[N / 2] - dist_[0];
219 template <
typename S, std::
size_t N>
223 return dist_[N / 2 + 1] - dist_[1];
227 template <
typename S, std::
size_t N>
231 return dist_[N / 2 + 2] - dist_[2];
235 template <
typename S, std::
size_t N>
239 return width() * height() * depth();
243 template <
typename S, std::
size_t N>
247 return width() * width() + height() * height() + depth() * depth();
251 template <
typename S, std::
size_t N>
255 return Vector3<S>(dist_[0] + dist_[N / 2], dist_[1] + dist_[N / 2 + 1], dist_[2] + dist_[N / 2 + 2]) * 0.5;
259 template <
typename S, std::
size_t N>
267 std::cerr <<
"KDOP distance not implemented!\n";
272 template <
typename S, std::
size_t N>
280 template <
typename S, std::
size_t N>
288 template <
typename S, std::
size_t N,
typename Derived>
291 const KDOP<S, N>& bv,
const Eigen::MatrixBase<Derived>& t)
294 for(std::size_t i = 0; i < 3; ++i)
297 res.
dist(N / 2 + i) += t[i];
302 for(std::size_t i = 0; i < (N - 6) / 2; ++i)
304 res.
dist(3 + i) += d[i];
305 res.
dist(3 + i + N / 2) += d[i];
312 template <
typename S>
329 template <
typename S>
333 if(p > maxv) maxv = p;
334 if(p < minv) minv = p;
338 template <
typename S, std::
size_t N>
348 template <
typename S, std::
size_t N>
356 template <
typename S>
370 template <
typename S>
385 template <
typename S>
396 d[6] = p[0] + p[1] - p[2];
397 d[7] = p[0] + p[2] - p[1];
398 d[8] = p[1] + p[2] - p[0];
template void minmax(double a, double b, double &minv, double &maxv)
template void getDistances< double, 5 >(const Vector3< double > &p, double *d)
S volume() const
The (AABB) volume.
bool inside(const Vector3< S > &p) const
S depth() const
The (AABB) depth.
FCL_EXPORT void getDistances(const Vector3< S > &p, S *d)
Compute the distances to planes with normals from KDOP vectors except those of AABB face planes...
static void run(const Vector3< S > &p, S *d)
KDOP()
Creating kDOP containing nothing.
KDOP< S, N > & operator+=(const Vector3< S > &p)
Merge the point and the KDOP.
AABB< S > translate(const AABB< S > &aabb, const Eigen::MatrixBase< Derived > &t)
translate the center of AABB by t
S dist_[N]
Origin's distances to N KDOP planes.
S height() const
The (AABB) height.
S distance(const KDOP< S, N > &other, Vector3< S > *P=nullptr, Vector3< S > *Q=nullptr) const
The distance between two KDOP<S, N>. Not implemented.
template class FCL_EXPORT KDOP< double, 24 >
S dist(std::size_t i) const
Eigen::Matrix< S, 3, 1 > Vector3
template class FCL_EXPORT KDOP< double, 16 >
template class FCL_EXPORT KDOP< double, 18 >
KDOP class describes the KDOP collision structures. K is set as the template parameter, which should be 16, 18, or 24 The KDOP structure is defined by some pairs of parallel planes defined by some axes. For K = 16, the planes are 6 AABB planes and 10 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 8 (0,-1,0) and (0,1,0) -> indices 1 and 9 (0,0,-1) and (0,0,1) -> indices 2 and 10 (-1,-1,0) and (1,1,0) -> indices 3 and 11 (-1,0,-1) and (1,0,1) -> indices 4 and 12 (0,-1,-1) and (0,1,1) -> indices 5 and 13 (-1,1,0) and (1,-1,0) -> indices 6 and 14 (-1,0,1) and (1,0,-1) -> indices 7 and 15 For K = 18, the planes are 6 AABB planes and 12 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 9 (0,-1,0) and (0,1,0) -> indices 1 and 10 (0,0,-1) and (0,0,1) -> indices 2 and 11 (-1,-1,0) and (1,1,0) -> indices 3 and 12 (-1,0,-1) and (1,0,1) -> indices 4 and 13 (0,-1,-1) and (0,1,1) -> indices 5 and 14 (-1,1,0) and (1,-1,0) -> indices 6 and 15 (-1,0,1) and (1,0,-1) -> indices 7 and 16 (0,-1,1) and (0,1,-1) -> indices 8 and 17 For K = 18, the planes are 6 AABB planes and 18 diagonal planes that cut off some space of the edges: (-1,0,0) and (1,0,0) -> indices 0 and 12 (0,-1,0) and (0,1,0) -> indices 1 and 13 (0,0,-1) and (0,0,1) -> indices 2 and 14 (-1,-1,0) and (1,1,0) -> indices 3 and 15 (-1,0,-1) and (1,0,1) -> indices 4 and 16 (0,-1,-1) and (0,1,1) -> indices 5 and 17 (-1,1,0) and (1,-1,0) -> indices 6 and 18 (-1,0,1) and (1,0,-1) -> indices 7 and 19 (0,-1,1) and (0,1,-1) -> indices 8 and 20 (-1, -1, 1) and (1, 1, -1) –> indices 9 and 21 (-1, 1, -1) and (1, -1, 1) –> indices 10 and 22 (1, -1, -1) and (-1, 1, 1) –> indices 11 and 23.
static void run(const Vector3< S > &p, S *d)
template void getDistances< double, 9 >(const Vector3< double > &p, double *d)
static void run(const Vector3< S > &p, S *d)
template void getDistances< double, 6 >(const Vector3< double > &p, double *d)
KDOP< S, N > operator+(const KDOP< S, N > &other) const
Create a KDOP by mergin two KDOPs.
Vector3< S > center() const
The (AABB) center.
bool overlap(const KDOP< S, N > &other) const
Check whether two KDOPs are overlapped.
S width() const
The (AABB) width.
static void run(const Vector3< S > &, S *)
S size() const
Size of the kDOP (used in BV_Splitter to order two kDOPs)