Go to the documentation of this file.
51 Matrix3s extAxes(
b.axes *
b.extent.asDiagonal());
52 vertices[0].noalias() =
b.To + extAxes *
Vec3s(-1, -1, -1);
53 vertices[1].noalias() =
b.To + extAxes *
Vec3s(1, -1, -1);
54 vertices[2].noalias() =
b.To + extAxes *
Vec3s(1, 1, -1);
55 vertices[3].noalias() =
b.To + extAxes *
Vec3s(-1, 1, -1);
56 vertices[4].noalias() =
b.To + extAxes *
Vec3s(-1, -1, 1);
57 vertices[5].noalias() =
b.To + extAxes *
Vec3s(1, -1, 1);
58 vertices[6].noalias() =
b.To + extAxes *
Vec3s(1, 1, 1);
59 vertices[7].noalias() =
b.To + extAxes *
Vec3s(-1, 1, 1);
73 b.axes.col(0).noalias() = (b1.
To - b2.
To).normalized();
75 Vec3s vertex_proj[16];
76 for (
int i = 0; i < 16; ++i)
77 vertex_proj[i].noalias() =
78 vertex[i] -
b.axes.col(0) * vertex[i].dot(
b.axes.col(0));
94 }
else if (s[2] > s[max]) {
101 b.axes.col(1) << E[0][max], E[1][max], E[2][max];
102 b.axes.col(2) << E[0][mid], E[1][mid], E[2][mid];
105 Vec3s center, extent;
108 b.To.noalias() = center;
109 b.extent.noalias() = extent;
117 b.To = (b1.
To + b2.
To) * 0.5;
119 if (q0.dot(
q1) < 0)
q1.coeffs() *= -1;
121 Quatf q((q0.coeffs() +
q1.coeffs()).normalized());
122 b.axes =
q.toRotationMatrix();
124 Vec3s vertex[8], diff;
125 CoalScalar real_max = (std::numeric_limits<CoalScalar>::max)();
126 Vec3s pmin(real_max, real_max, real_max);
127 Vec3s pmax(-real_max, -real_max, -real_max);
130 for (
int i = 0; i < 8; ++i) {
131 diff = vertex[i] -
b.To;
132 for (
int j = 0; j < 3; ++j) {
136 else if (dot < pmin[j])
142 for (
int i = 0; i < 8; ++i) {
143 diff = vertex[i] -
b.To;
144 for (
int j = 0; j < 3; ++j) {
148 else if (dot < pmin[j])
153 for (
int j = 0; j < 3; ++j) {
154 b.To.noalias() += (
b.axes.col(j) * (0.5 * (pmax[j] + pmin[j])));
155 b.extent[j] = 0.5 * (pmax[j] - pmin[j]);
172 t = ((T[0] < 0.0) ? -T[0] : T[0]);
175 if (
t > (
a[0] + Bf.row(0).dot(
b)))
return true;
180 t = ((s < 0.0) ? -s : s);
183 if (
t > (
b[0] + Bf.col(0).dot(
a)))
return true;
186 t = ((T[1] < 0.0) ? -T[1] : T[1]);
189 if (
t > (
a[1] + Bf.row(1).dot(
b)))
return true;
192 t = ((T[2] < 0.0) ? -T[2] : T[2]);
195 if (
t > (
a[2] + Bf.row(2).dot(
b)))
return true;
200 t = ((s < 0.0) ? -s : s);
203 if (
t > (
b[1] + Bf.col(1).dot(
a)))
return true;
208 t = ((s < 0.0) ? -s : s);
211 if (
t > (
b[2] + Bf.col(2).dot(
a)))
return true;
214 s = T[2] *
B(1, 0) - T[1] *
B(2, 0);
215 t = ((s < 0.0) ? -s : s);
218 (
a[1] * Bf(2, 0) +
a[2] * Bf(1, 0) +
b[1] * Bf(0, 2) +
b[2] * Bf(0, 1)))
222 s = T[2] *
B(1, 1) - T[1] *
B(2, 1);
223 t = ((s < 0.0) ? -s : s);
226 (
a[1] * Bf(2, 1) +
a[2] * Bf(1, 1) +
b[0] * Bf(0, 2) +
b[2] * Bf(0, 0)))
230 s = T[2] *
B(1, 2) - T[1] *
B(2, 2);
231 t = ((s < 0.0) ? -s : s);
234 (
a[1] * Bf(2, 2) +
a[2] * Bf(1, 2) +
b[0] * Bf(0, 1) +
b[1] * Bf(0, 0)))
238 s = T[0] *
B(2, 0) - T[2] *
B(0, 0);
239 t = ((s < 0.0) ? -s : s);
242 (
a[0] * Bf(2, 0) +
a[2] * Bf(0, 0) +
b[1] * Bf(1, 2) +
b[2] * Bf(1, 1)))
246 s = T[0] *
B(2, 1) - T[2] *
B(0, 1);
247 t = ((s < 0.0) ? -s : s);
250 (
a[0] * Bf(2, 1) +
a[2] * Bf(0, 1) +
b[0] * Bf(1, 2) +
b[2] * Bf(1, 0)))
254 s = T[0] *
B(2, 2) - T[2] *
B(0, 2);
255 t = ((s < 0.0) ? -s : s);
258 (
a[0] * Bf(2, 2) +
a[2] * Bf(0, 2) +
b[0] * Bf(1, 1) +
b[1] * Bf(1, 0)))
262 s = T[1] *
B(0, 0) - T[0] *
B(1, 0);
263 t = ((s < 0.0) ? -s : s);
266 (
a[0] * Bf(1, 0) +
a[1] * Bf(0, 0) +
b[1] * Bf(2, 2) +
b[2] * Bf(2, 1)))
270 s = T[1] *
B(0, 1) - T[0] *
B(1, 1);
271 t = ((s < 0.0) ? -s : s);
274 (
a[0] * Bf(1, 1) +
a[1] * Bf(0, 1) +
b[0] * Bf(2, 2) +
b[2] * Bf(2, 0)))
278 s = T[1] *
B(0, 2) - T[0] *
B(1, 2);
279 t = ((s < 0.0) ? -s : s);
282 (
a[0] * Bf(1, 2) +
a[1] * Bf(0, 2) +
b[0] * Bf(2, 1) +
b[1] * Bf(2, 0)))
292 Vec3s AABB_corner(T.cwiseAbs() -
a);
293 AABB_corner.noalias() -= Bf *
b;
294 return AABB_corner.array().max(
CoalScalar(0)).matrix().squaredNorm();
303 s = std::abs(
B.col(0).dot(T)) - Bf.col(0).dot(
a) -
b[0];
304 if (s > 0)
t += s * s;
305 s = std::abs(
B.col(1).dot(T)) - Bf.col(1).dot(
a) -
b[1];
306 if (s > 0)
t += s * s;
307 s = std::abs(
B.col(2).dot(T)) - Bf.col(2).dot(
a) -
b[2];
308 if (s > 0)
t += s * s;
312 template <
int ib,
int jb = (ib + 1) % 3,
int kb = (ib + 2) % 3>
317 1 - Bf(ia, ib) * Bf(ia, ib);
318 if (sinus2 < 1e-6)
return false;
320 const CoalScalar s = T[ka] *
B(ja, ib) - T[ja] *
B(ka, ib);
322 const CoalScalar diff = fabs(s) - (
a[ja] * Bf(ka, ib) +
a[ka] * Bf(ja, ib) +
323 b[jb] * Bf(ia, kb) +
b[kb] * Bf(ia, jb));
327 squaredLowerBoundDistance = diff * diff / sinus2;
328 if (squaredLowerBoundDistance > breakDistance2) {
348 -2 * (std::min)(a_.minCoeff(), b_.minCoeff()) -
350 "A negative security margin could not be lower than the OBB extent.");
366 if (squaredLowerBoundDistance > breakDistance2)
return true;
368 squaredLowerBoundDistance =
370 if (squaredLowerBoundDistance > breakDistance2)
return true;
374 for (
int ia = 0; ia < 3; ++ia) {
376 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
377 squaredLowerBoundDistance))
380 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
381 squaredLowerBoundDistance))
384 ia, ja, ka,
B, T,
a,
b, Bf, breakDistance2,
385 squaredLowerBoundDistance))
427 if ((proj >
extent[0]) || (proj < -
extent[0]))
return false;
429 proj = local_p.dot(
axes.col(1));
430 if ((proj >
extent[1]) || (proj < -
extent[1]))
return false;
432 proj = local_p.dot(
axes.col(2));
433 if ((proj >
extent[2]) || (proj < -
extent[2]))
return false;
453 if (center_diff.norm() > 2 * (max_extent + max_extent2)) {
462 std::cerr <<
"OBB distance not implemented!" << std::endl;
468 Vec3s Ttemp(R0.transpose() * (b2.
To - T0) - b1.
To);
477 Vec3s Ttemp(R0.transpose() * (b2.
To - T0) - b1.
To);
void computeVertices(const OBB &b, Vec3s vertices[8])
Compute the 8 vertices of a OBB.
OBB & operator+=(const Vec3s &p)
A simple way to merge the OBB and a point (the result is not compact).
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
bool obbDisjointAndLowerBoundDistance(const Matrix3s &B, const Vec3s &T, const Vec3s &a_, const Vec3s &b_, const CollisionRequest &request, CoalScalar &squaredLowerBoundDistance)
CoalScalar obbDisjoint_check_B_axis(const Matrix3s &B, const Vec3s &T, const Vec3s &a, const Vec3s &b, const Matrix3s &Bf)
bool contain(const Vec3s &p) const
Check whether the OBB contains a point.
Vec3s extent
Half dimensions of OBB.
CoalScalar obbDisjoint_check_A_axis(const Vec3s &T, const Vec3s &a, const Vec3s &b, const Matrix3s &Bf)
CoalScalar security_margin
Distance below which objects are considered in collision. See Collision.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Matrix3s axes
Orientation of OBB. axis[i] is the ith column of the orientation matrix for the box; it is also the i...
Eigen::Quaternion< CoalScalar > Quatf
COAL_DLLAPI bool obbDisjoint(const Matrix3s &B, const Vec3s &T, const Vec3s &a, const Vec3s &b)
COAL_DLLAPI void getExtentAndCenter(Vec3s *ps, Vec3s *ps2, Triangle *ts, unsigned int *indices, unsigned int n, Matrix3s &axes, Vec3s ¢er, Vec3s &extent)
Compute the bounding volume extent and center for a set or subset of points, given the BV axises.
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...
bool overlap(const OBB &other) const
static bool run(int ia, int ja, int ka, const Matrix3s &B, const Vec3s &T, const Vec3s &a, const Vec3s &b, const Matrix3s &Bf, const CoalScalar &breakDistance2, CoalScalar &squaredLowerBoundDistance)
OBB merge_smalldist(const OBB &b1, const OBB &b2)
OBB merge method when the centers of two smaller OBB are close.
OBB operator+(const OBB &other) const
Return the merged OBB of current OBB and the other one (the result is not compact).
request to the collision algorithm
static AABB translate(const AABB &aabb, const Vec3s &t)
translate the center of AABB by t
CoalScalar distance(const OBB &other, Vec3s *P=NULL, Vec3s *Q=NULL) const
Distance between two OBBs, not implemented.
COAL_DLLAPI bool overlap(const Matrix3s &R0, const Vec3s &T0, const AABB &b1, const AABB &b2)
Check collision between two aabbs, b1 is in configuration (R0, T0) and b2 is in identity.
static CoalScalar epsilon
Eigen::Matrix< CoalScalar, 3, 3 > Matrix3s
COAL_DLLAPI void getCovariance(Vec3s *ps, Vec3s *ps2, Triangle *ts, unsigned int *indices, unsigned int n, Matrix3s &M)
Compute the covariance matrix for a set or subset of points. if ts = null, then indices refer to poin...
OBB merge_largedist(const OBB &b1, const OBB &b2)
OBB merge method when the centers of two smaller OBB are far away.
Oriented bounding box class.
CoalScalar break_distance
Distance below which bounding volumes are broken down. See Collision.
hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:58