Go to the documentation of this file.
52 Matrix3f extAxes(
b.axes *
b.extent.asDiagonal());
53 vertices[0].noalias() =
b.To + extAxes *
Vec3f(-1, -1, -1);
54 vertices[1].noalias() =
b.To + extAxes *
Vec3f(1, -1, -1);
55 vertices[2].noalias() =
b.To + extAxes *
Vec3f(1, 1, -1);
56 vertices[3].noalias() =
b.To + extAxes *
Vec3f(-1, 1, -1);
57 vertices[4].noalias() =
b.To + extAxes *
Vec3f(-1, -1, 1);
58 vertices[5].noalias() =
b.To + extAxes *
Vec3f(1, -1, 1);
59 vertices[6].noalias() =
b.To + extAxes *
Vec3f(1, 1, 1);
60 vertices[7].noalias() =
b.To + extAxes *
Vec3f(-1, 1, 1);
71 Matrix3f::Scalar s[3] = {0, 0, 0};
74 b.axes.col(0).noalias() = (b1.
To - b2.
To).normalized();
76 Vec3f vertex_proj[16];
77 for (
int i = 0; i < 16; ++i)
78 vertex_proj[i].noalias() =
79 vertex[i] -
b.axes.col(0) * vertex[i].dot(
b.axes.col(0));
95 }
else if (s[2] > s[max]) {
102 b.axes.col(1) << E[0][max], E[1][max], E[2][max];
103 b.axes.col(2) << E[0][mid], E[1][mid], E[2][mid];
106 Vec3f center, extent;
109 b.To.noalias() = center;
110 b.extent.noalias() = extent;
118 b.To = (b1.
To + b2.
To) * 0.5;
120 if (q0.dot(
q1) < 0)
q1.coeffs() *= -1;
123 b.axes =
q.toRotationMatrix();
125 Vec3f vertex[8], diff;
126 FCL_REAL real_max = (std::numeric_limits<FCL_REAL>::max)();
127 Vec3f pmin(real_max, real_max, real_max);
128 Vec3f pmax(-real_max, -real_max, -real_max);
131 for (
int i = 0; i < 8; ++i) {
132 diff = vertex[i] -
b.To;
133 for (
int j = 0; j < 3; ++j) {
137 else if (dot < pmin[j])
143 for (
int i = 0; i < 8; ++i) {
144 diff = vertex[i] -
b.To;
145 for (
int j = 0; j < 3; ++j) {
149 else if (dot < pmin[j])
154 for (
int j = 0; j < 3; ++j) {
155 b.To.noalias() += (
b.axes.col(j) * (0.5 * (pmax[j] + pmin[j])));
156 b.extent[j] = 0.5 * (pmax[j] - pmin[j]);
173 t = ((T[0] < 0.0) ? -T[0] : T[0]);
176 if (
t > (
a[0] + Bf.row(0).dot(
b)))
return true;
181 t = ((s < 0.0) ? -s : s);
184 if (
t > (
b[0] + Bf.col(0).dot(
a)))
return true;
187 t = ((T[1] < 0.0) ? -T[1] : T[1]);
190 if (
t > (
a[1] + Bf.row(1).dot(
b)))
return true;
193 t = ((T[2] < 0.0) ? -T[2] : T[2]);
196 if (
t > (
a[2] + Bf.row(2).dot(
b)))
return true;
201 t = ((s < 0.0) ? -s : s);
204 if (
t > (
b[1] + Bf.col(1).dot(
a)))
return true;
209 t = ((s < 0.0) ? -s : s);
212 if (
t > (
b[2] + Bf.col(2).dot(
a)))
return true;
215 s = T[2] *
B(1, 0) - T[1] *
B(2, 0);
216 t = ((s < 0.0) ? -s : s);
219 (
a[1] * Bf(2, 0) +
a[2] * Bf(1, 0) +
b[1] * Bf(0, 2) +
b[2] * Bf(0, 1)))
223 s = T[2] *
B(1, 1) - T[1] *
B(2, 1);
224 t = ((s < 0.0) ? -s : s);
227 (
a[1] * Bf(2, 1) +
a[2] * Bf(1, 1) +
b[0] * Bf(0, 2) +
b[2] * Bf(0, 0)))
231 s = T[2] *
B(1, 2) - T[1] *
B(2, 2);
232 t = ((s < 0.0) ? -s : s);
235 (
a[1] * Bf(2, 2) +
a[2] * Bf(1, 2) +
b[0] * Bf(0, 1) +
b[1] * Bf(0, 0)))
239 s = T[0] *
B(2, 0) - T[2] *
B(0, 0);
240 t = ((s < 0.0) ? -s : s);
243 (
a[0] * Bf(2, 0) +
a[2] * Bf(0, 0) +
b[1] * Bf(1, 2) +
b[2] * Bf(1, 1)))
247 s = T[0] *
B(2, 1) - T[2] *
B(0, 1);
248 t = ((s < 0.0) ? -s : s);
251 (
a[0] * Bf(2, 1) +
a[2] * Bf(0, 1) +
b[0] * Bf(1, 2) +
b[2] * Bf(1, 0)))
255 s = T[0] *
B(2, 2) - T[2] *
B(0, 2);
256 t = ((s < 0.0) ? -s : s);
259 (
a[0] * Bf(2, 2) +
a[2] * Bf(0, 2) +
b[0] * Bf(1, 1) +
b[1] * Bf(1, 0)))
263 s = T[1] *
B(0, 0) - T[0] *
B(1, 0);
264 t = ((s < 0.0) ? -s : s);
267 (
a[0] * Bf(1, 0) +
a[1] * Bf(0, 0) +
b[1] * Bf(2, 2) +
b[2] * Bf(2, 1)))
271 s = T[1] *
B(0, 1) - T[0] *
B(1, 1);
272 t = ((s < 0.0) ? -s : s);
275 (
a[0] * Bf(1, 1) +
a[1] * Bf(0, 1) +
b[0] * Bf(2, 2) +
b[2] * Bf(2, 0)))
279 s = T[1] *
B(0, 2) - T[0] *
B(1, 2);
280 t = ((s < 0.0) ? -s : s);
283 (
a[0] * Bf(1, 2) +
a[1] * Bf(0, 2) +
b[0] * Bf(2, 1) +
b[1] * Bf(2, 0)))
293 Vec3f AABB_corner(T.cwiseAbs() -
a);
294 AABB_corner.noalias() -= Bf *
b;
295 return AABB_corner.array().max(
FCL_REAL(0)).matrix().squaredNorm();
304 s = std::abs(
B.col(0).dot(T)) - Bf.col(0).dot(
a) -
b[0];
305 if (s > 0)
t += s * s;
306 s = std::abs(
B.col(1).dot(T)) - Bf.col(1).dot(
a) -
b[1];
307 if (s > 0)
t += s * s;
308 s = std::abs(
B.col(2).dot(T)) - Bf.col(2).dot(
a) -
b[2];
309 if (s > 0)
t += s * s;
313 template <
int ib,
int jb = (ib + 1) % 3,
int kb = (ib + 2) % 3>
318 FCL_REAL& squaredLowerBoundDistance) {
319 FCL_REAL sinus2 = 1 - Bf(ia, ib) * Bf(ia, ib);
320 if (sinus2 < 1e-6)
return false;
322 const FCL_REAL s = T[ka] *
B(ja, ib) - T[ja] *
B(ka, ib);
324 const FCL_REAL diff = fabs(s) - (
a[ja] * Bf(ka, ib) +
a[ka] * Bf(ja, ib) +
325 b[jb] * Bf(ia, kb) +
b[kb] * Bf(ia, jb));
329 squaredLowerBoundDistance = diff * diff / sinus2;
330 if (squaredLowerBoundDistance > breakDistance2) {
348 FCL_REAL& squaredLowerBoundDistance) {
350 -2 * (std::min)(a_.minCoeff(), b_.minCoeff()) -
352 "A negative security margin could not be lower than the OBB extent.");
368 if (squaredLowerBoundDistance > breakDistance2)
return true;
370 squaredLowerBoundDistance =
372 if (squaredLowerBoundDistance > breakDistance2)
return true;
376 for (
int ia = 0; ia < 3; ++ia) {
378 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
379 squaredLowerBoundDistance))
382 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
383 squaredLowerBoundDistance))
386 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
387 squaredLowerBoundDistance))
407 FCL_REAL& sqrDistLowerBound)
const {
429 if ((proj >
extent[0]) || (proj < -
extent[0]))
return false;
431 proj = local_p.dot(
axes.col(1));
432 if ((proj >
extent[1]) || (proj < -
extent[1]))
return false;
434 proj = local_p.dot(
axes.col(2));
435 if ((proj >
extent[2]) || (proj < -
extent[2]))
return false;
455 if (center_diff.norm() > 2 * (max_extent + max_extent2)) {
463 std::cerr <<
"OBB distance not implemented!" << std::endl;
469 Vec3f Ttemp(R0.transpose() * (b2.
To - T0) - b1.
To);
478 Vec3f Ttemp(R0.transpose() * (b2.
To - T0) - b1.
To);
Matrix3f axes
Orientation of OBB. axis[i] is the ith column of the orientation matrix for the box; it is also the i...
Vec3f extent
Half dimensions of OBB.
FCL_REAL distance(const OBB &other, Vec3f *P=NULL, Vec3f *Q=NULL) const
Distance between two OBBs, not implemented.
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
OBB merge_smalldist(const OBB &b1, const OBB &b2)
OBB merge method when the centers of two smaller OBB are close.
FCL_REAL break_distance
Distance below which bounding volumes are broken down. See Collision.
OBB merge_largedist(const OBB &b1, const OBB &b2)
OBB merge method when the centers of two smaller OBB are far away.
static bool run(int ia, int ja, int ka, const Matrix3f &B, const Vec3f &T, const Vec3f &a, const Vec3f &b, const Matrix3f &Bf, const FCL_REAL &breakDistance2, FCL_REAL &squaredLowerBoundDistance)
HPP_FCL_DLLAPI void getCovariance(Vec3f *ps, Vec3f *ps2, Triangle *ts, unsigned int *indices, unsigned int n, Matrix3f &M)
Compute the covariance matrix for a set or subset of points. if ts = null, then indices refer to poin...
void eigen(const Eigen::MatrixBase< Derived > &m, typename Derived::Scalar dout[3], Vector *vout)
compute the eigen vector and eigen vector of a matrix. dout is the eigen values, vout is the eigen ve...
HPP_FCL_DLLAPI void getExtentAndCenter(Vec3f *ps, Vec3f *ps2, Triangle *ts, unsigned int *indices, unsigned int n, Matrix3f &axes, Vec3f ¢er, Vec3f &extent)
Compute the bounding volume extent and center for a set or subset of points, given the BV axises.
OBB operator+(const OBB &other) const
Return the merged OBB of current OBB and the other one (the result is not compact).
bool overlap(const OBB &other) const
FCL_REAL security_margin
Distance below which objects are considered in collision. See Collision.
HPP_FCL_DLLAPI bool obbDisjoint(const Matrix3f &B, const Vec3f &T, const Vec3f &a, const Vec3f &b)
request to the collision algorithm
Oriented bounding box class.
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
OBB & operator+=(const Vec3f &p)
A simple way to merge the OBB and a point (the result is not compact).
HPP_FCL_DLLAPI bool overlap(const Matrix3f &R0, const Vec3f &T0, const AABB &b1, const AABB &b2)
Check collision between two aabbs, b1 is in configuration (R0, T0) and b2 is in identity.
FCL_REAL obbDisjoint_check_B_axis(const Matrix3f &B, const Vec3f &T, const Vec3f &a, const Vec3f &b, const Matrix3f &Bf)
bool obbDisjointAndLowerBoundDistance(const Matrix3f &B, const Vec3f &T, const Vec3f &a_, const Vec3f &b_, const CollisionRequest &request, FCL_REAL &squaredLowerBoundDistance)
bool contain(const Vec3f &p) const
Check whether the OBB contains a point.
static AABB translate(const AABB &aabb, const Vec3f &t)
translate the center of AABB by t
FCL_REAL obbDisjoint_check_A_axis(const Vec3f &T, const Vec3f &a, const Vec3f &b, const Matrix3f &Bf)
Eigen::Quaternion< FCL_REAL > Quaternion3f
void computeVertices(const OBB &b, Vec3f vertices[8])
Compute the 8 vertices of a OBB.
hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14