38 #ifndef FCL_GEOMETRY_SHAPE_UTILITY_INL_H 39 #define FCL_GEOMETRY_SHAPE_UTILITY_INL_H 41 #include "fcl/geometry/shape/utility.h" 43 #include "fcl/math/bv/utility.h" 45 #include "fcl/geometry/shape/capsule.h" 46 #include "fcl/geometry/shape/cone.h" 47 #include "fcl/geometry/shape/convex.h" 48 #include "fcl/geometry/shape/cylinder.h" 49 #include "fcl/geometry/shape/ellipsoid.h" 50 #include "fcl/geometry/shape/halfspace.h" 51 #include "fcl/geometry/shape/plane.h" 52 #include "fcl/geometry/shape/sphere.h" 53 #include "fcl/geometry/shape/triangle_p.h" 59 void constructBox(
const OBB<double>& bv, Box<double>& box, Transform3<double>& tf);
63 void constructBox(
const OBBRSS<double>& bv, Box<double>& box, Transform3<double>& tf);
67 void constructBox(
const kIOS<double>& bv, Box<double>& box, Transform3<double>& tf);
71 void constructBox(
const RSS<double>& bv, Box<double>& box, Transform3<double>& tf);
75 void constructBox(
const KDOP<double, 16>& bv, Box<double>& box, Transform3<double>& tf);
79 void constructBox(
const KDOP<double, 18>& bv, Box<double>& box, Transform3<double>& tf);
83 void constructBox(
const KDOP<double, 24>& bv, Box<double>& box, Transform3<double>& tf);
87 void constructBox(
const AABB<double>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
91 void constructBox(
const OBB<double>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
95 void constructBox(
const OBBRSS<double>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
99 void constructBox(
const kIOS<double>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
103 void constructBox(
const RSS<double>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
107 void constructBox(
const KDOP<double, 16>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
111 void constructBox(
const KDOP<double, 18>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
115 void constructBox(
const KDOP<double, 24>& bv,
const Transform3<double>& tf_bv, Box<double>& box, Transform3<double>& tf);
122 template <
typename S,
typename BV,
typename Shape>
125 static void run(
const Shape& s,
const Transform3<S>& tf, BV& bv)
127 std::vector<Vector3<S>> convex_bound_vertices = s.getBoundVertices(tf);
128 fit(&convex_bound_vertices[0], (
int)convex_bound_vertices.size(), bv);
133 template <
typename S>
136 static void run(
const Box<S>& s,
const Transform3<S>& tf,
AABB<S>& bv)
138 const Matrix3<S>& R = tf.linear();
139 const Vector3<S>& T = tf.translation();
141 S x_range = 0.5 * (fabs(R(0, 0) * s.
side[0]) + fabs(R(0, 1) * s.
side[1]) + fabs(R(0, 2) * s.
side[2]));
142 S y_range = 0.5 * (fabs(R(1, 0) * s.
side[0]) + fabs(R(1, 1) * s.
side[1]) + fabs(R(1, 2) * s.
side[2]));
143 S z_range = 0.5 * (fabs(R(2, 0) * s.
side[0]) + fabs(R(2, 1) * s.
side[1]) + fabs(R(2, 2) * s.
side[2]));
145 Vector3<S> v_delta(x_range, y_range, z_range);
146 bv.
max_ = T + v_delta;
147 bv.
min_ = T - v_delta;
152 template <
typename S>
155 static void run(
const Box<S>& s,
const Transform3<S>& tf,
OBB<S>& bv)
157 bv.
axis = tf.linear();
158 bv.
To = tf.translation();
164 template <
typename S>
169 const Matrix3<S>& R = tf.linear();
170 const Vector3<S>& T = tf.translation();
172 S x_range = 0.5 * fabs(R(0, 2) * s.
lz) + s.
radius;
173 S y_range = 0.5 * fabs(R(1, 2) * s.
lz) + s.
radius;
174 S z_range = 0.5 * fabs(R(2, 2) * s.
lz) + s.
radius;
176 Vector3<S> v_delta(x_range, y_range, z_range);
177 bv.
max_ = T + v_delta;
178 bv.
min_ = T - v_delta;
183 template <
typename S>
188 bv.
axis = tf.linear();
189 bv.
To = tf.translation();
195 template <
typename S>
198 static void run(
const Cone<S>& s,
const Transform3<S>& tf,
AABB<S>& bv)
200 const Matrix3<S>& R = tf.linear();
201 const Vector3<S>& T = tf.translation();
203 S x_range = fabs(R(0, 0) * s.
radius) + fabs(R(0, 1) * s.
radius) + 0.5 * fabs(R(0, 2) * s.
lz);
204 S y_range = fabs(R(1, 0) * s.
radius) + fabs(R(1, 1) * s.
radius) + 0.5 * fabs(R(1, 2) * s.
lz);
205 S z_range = fabs(R(2, 0) * s.
radius) + fabs(R(2, 1) * s.
radius) + 0.5 * fabs(R(2, 2) * s.
lz);
207 Vector3<S> v_delta(x_range, y_range, z_range);
208 bv.
max_ = T + v_delta;
209 bv.
min_ = T - v_delta;
214 template <
typename S>
217 static void run(
const Cone<S>& s,
const Transform3<S>& tf,
OBB<S>& bv)
219 bv.
axis = tf.linear();
220 bv.
To = tf.translation();
226 template <
typename S>
231 const Matrix3<S>& R = tf.linear();
232 const Vector3<S>& T = tf.translation();
235 for(
int i = 0; i < s.num_points; ++i)
237 Vector3<S> new_p = R * s.points[i] + T;
246 template <
typename S>
249 static void run(
const Convex<S>& s,
const Transform3<S>& tf,
OBB<S>& bv)
251 fit(s.points, s.num_points, bv);
253 bv.
axis = tf.linear();
259 template <
typename S>
264 const Matrix3<S>& R = tf.linear();
265 const Vector3<S>& T = tf.translation();
267 S x_range = fabs(R(0, 0) * s.
radius) + fabs(R(0, 1) * s.
radius) + 0.5 * fabs(R(0, 2) * s.
lz);
268 S y_range = fabs(R(1, 0) * s.
radius) + fabs(R(1, 1) * s.
radius) + 0.5 * fabs(R(1, 2) * s.
lz);
269 S z_range = fabs(R(2, 0) * s.
radius) + fabs(R(2, 1) * s.
radius) + 0.5 * fabs(R(2, 2) * s.
lz);
271 Vector3<S> v_delta(x_range, y_range, z_range);
272 bv.
max_ = T + v_delta;
273 bv.
min_ = T - v_delta;
278 template <
typename S>
283 bv.
axis = tf.linear();
284 bv.
To = tf.translation();
290 template <
typename S>
295 const Matrix3<S>& R = tf.linear();
296 const Vector3<S>& T = tf.translation();
298 S x_range = (fabs(R(0, 0) * s.
radii[0]) + fabs(R(0, 1) * s.
radii[1]) + fabs(R(0, 2) * s.
radii[2]));
299 S y_range = (fabs(R(1, 0) * s.
radii[0]) + fabs(R(1, 1) * s.
radii[1]) + fabs(R(1, 2) * s.
radii[2]));
300 S z_range = (fabs(R(2, 0) * s.
radii[0]) + fabs(R(2, 1) * s.
radii[1]) + fabs(R(2, 2) * s.
radii[2]));
302 Vector3<S> v_delta(x_range, y_range, z_range);
303 bv.
max_ = T + v_delta;
304 bv.
min_ = T - v_delta;
309 template <
typename S>
314 bv.
axis = tf.linear();
315 bv.
To = tf.translation();
321 template <
typename S>
327 const Vector3<S>& n = new_s.
n;
328 const S& d = new_s.
d;
331 bv_.
min_ = Vector3<S>::Constant(-std::numeric_limits<S>::max());
332 bv_.
max_ = Vector3<S>::Constant(std::numeric_limits<S>::max());
333 if(n[1] == (S)0.0 && n[2] == (S)0.0)
336 if(n[0] < 0) bv_.
min_[0] = -d;
337 else if(n[0] > 0) bv_.
max_[0] = d;
339 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
342 if(n[1] < 0) bv_.
min_[1] = -d;
343 else if(n[1] > 0) bv_.
max_[1] = d;
345 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
348 if(n[2] < 0) bv_.
min_[2] = -d;
349 else if(n[2] > 0) bv_.
max_[2] = d;
357 template <
typename S>
363 bv.
axis.setIdentity();
365 bv.
extent.setConstant(std::numeric_limits<S>::max());
370 template <
typename S>
376 bv.
axis.setIdentity();
378 bv.
l[0] = bv.
l[1] = bv.
r = std::numeric_limits<S>::max();
383 template <
typename S>
394 template <
typename S>
402 bv.
spheres[0].r = std::numeric_limits<S>::max();
407 template <
typename S>
413 const Vector3<S>& n = new_s.
n;
414 const S& d = new_s.
d;
416 const std::size_t D = 8;
417 for(std::size_t i = 0; i < D; ++i)
418 bv.dist(i) = -std::numeric_limits<S>::max();
419 for(std::size_t i = D; i < 2 * D; ++i)
420 bv.dist(i) = std::numeric_limits<S>::max();
422 if(n[1] == (S)0.0 && n[2] == (S)0.0)
424 if(n[0] > 0) bv.dist(D) = d;
425 else bv.dist(0) = -d;
427 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
429 if(n[1] > 0) bv.dist(D + 1) = d;
430 else bv.dist(1) = -d;
432 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
434 if(n[2] > 0) bv.dist(D + 2) = d;
435 else bv.dist(2) = -d;
437 else if(n[2] == (S)0.0 && n[0] == n[1])
439 if(n[0] > 0) bv.dist(D + 3) = n[0] * d * 2;
440 else bv.dist(3) = n[0] * d * 2;
442 else if(n[1] == (S)0.0 && n[0] == n[2])
444 if(n[1] > 0) bv.dist(D + 4) = n[0] * d * 2;
445 else bv.dist(4) = n[0] * d * 2;
447 else if(n[0] == (S)0.0 && n[1] == n[2])
449 if(n[1] > 0) bv.dist(D + 5) = n[1] * d * 2;
450 else bv.dist(5) = n[1] * d * 2;
452 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
454 if(n[0] > 0) bv.dist(D + 6) = n[0] * d * 2;
455 else bv.dist(6) = n[0] * d * 2;
457 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
459 if(n[0] > 0) bv.dist(D + 7) = n[0] * d * 2;
460 else bv.dist(7) = n[0] * d * 2;
466 template <
typename S>
472 const Vector3<S>& n = new_s.
n;
473 const S& d = new_s.
d;
475 const std::size_t D = 9;
477 for(std::size_t i = 0; i < D; ++i)
478 bv.dist(i) = -std::numeric_limits<S>::max();
479 for(std::size_t i = D; i < 2 * D; ++i)
480 bv.dist(i) = std::numeric_limits<S>::max();
482 if(n[1] == (S)0.0 && n[2] == (S)0.0)
484 if(n[0] > 0) bv.dist(D) = d;
485 else bv.dist(0) = -d;
487 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
489 if(n[1] > 0) bv.dist(D + 1) = d;
490 else bv.dist(1) = -d;
492 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
494 if(n[2] > 0) bv.dist(D + 2) = d;
495 else bv.dist(2) = -d;
497 else if(n[2] == (S)0.0 && n[0] == n[1])
499 if(n[0] > 0) bv.dist(D + 3) = n[0] * d * 2;
500 else bv.dist(3) = n[0] * d * 2;
502 else if(n[1] == (S)0.0 && n[0] == n[2])
504 if(n[1] > 0) bv.dist(D + 4) = n[0] * d * 2;
505 else bv.dist(4) = n[0] * d * 2;
507 else if(n[0] == (S)0.0 && n[1] == n[2])
509 if(n[1] > 0) bv.dist(D + 5) = n[1] * d * 2;
510 else bv.dist(5) = n[1] * d * 2;
512 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
514 if(n[0] > 0) bv.dist(D + 6) = n[0] * d * 2;
515 else bv.dist(6) = n[0] * d * 2;
517 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
519 if(n[0] > 0) bv.dist(D + 7) = n[0] * d * 2;
520 else bv.dist(7) = n[0] * d * 2;
522 else if(n[0] == (S)0.0 && n[1] + n[2] == (S)0.0)
524 if(n[1] > 0) bv.dist(D + 8) = n[1] * d * 2;
525 else bv.dist(8) = n[1] * d * 2;
531 template <
typename S>
537 const Vector3<S>& n = new_s.
n;
538 const S& d = new_s.
d;
540 const std::size_t D = 12;
542 for(std::size_t i = 0; i < D; ++i)
543 bv.dist(i) = -std::numeric_limits<S>::max();
544 for(std::size_t i = D; i < 2 * D; ++i)
545 bv.dist(i) = std::numeric_limits<S>::max();
547 if(n[1] == (S)0.0 && n[2] == (S)0.0)
549 if(n[0] > 0) bv.dist(D) = d;
550 else bv.dist(0) = -d;
552 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
554 if(n[1] > 0) bv.dist(D + 1) = d;
555 else bv.dist(1) = -d;
557 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
559 if(n[2] > 0) bv.dist(D + 2) = d;
560 else bv.dist(2) = -d;
562 else if(n[2] == (S)0.0 && n[0] == n[1])
564 if(n[0] > 0) bv.dist(D + 3) = n[0] * d * 2;
565 else bv.dist(3) = n[0] * d * 2;
567 else if(n[1] == (S)0.0 && n[0] == n[2])
569 if(n[1] > 0) bv.dist(D + 4) = n[0] * d * 2;
570 else bv.dist(4) = n[0] * d * 2;
572 else if(n[0] == (S)0.0 && n[1] == n[2])
574 if(n[1] > 0) bv.dist(D + 5) = n[1] * d * 2;
575 else bv.dist(5) = n[1] * d * 2;
577 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
579 if(n[0] > 0) bv.dist(D + 6) = n[0] * d * 2;
580 else bv.dist(6) = n[0] * d * 2;
582 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
584 if(n[0] > 0) bv.dist(D + 7) = n[0] * d * 2;
585 else bv.dist(7) = n[0] * d * 2;
587 else if(n[0] == (S)0.0 && n[1] + n[2] == (S)0.0)
589 if(n[1] > 0) bv.dist(D + 8) = n[1] * d * 2;
590 else bv.dist(8) = n[1] * d * 2;
592 else if(n[0] + n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
594 if(n[0] > 0) bv.dist(D + 9) = n[0] * d * 3;
595 else bv.dist(9) = n[0] * d * 3;
597 else if(n[0] + n[1] == (S)0.0 && n[1] + n[2] == (S)0.0)
599 if(n[0] > 0) bv.dist(D + 10) = n[0] * d * 3;
600 else bv.dist(10) = n[0] * d * 3;
602 else if(n[0] + n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
604 if(n[1] > 0) bv.dist(D + 11) = n[1] * d * 3;
605 else bv.dist(11) = n[1] * d * 3;
611 template <
typename S>
614 static void run(
const Plane<S>& s,
const Transform3<S>& tf,
AABB<S>& bv)
617 const Vector3<S>& n = new_s.
n;
618 const S& d = new_s.
d;
621 bv_.
min_ = Vector3<S>::Constant(-std::numeric_limits<S>::max());
622 bv_.
max_ = Vector3<S>::Constant(std::numeric_limits<S>::max());
623 if(n[1] == (S)0.0 && n[2] == (S)0.0)
626 if(n[0] < 0) { bv_.
min_[0] = bv_.
max_[0] = -d; }
627 else if(n[0] > 0) { bv_.
min_[0] = bv_.
max_[0] = d; }
629 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
632 if(n[1] < 0) { bv_.
min_[1] = bv_.
max_[1] = -d; }
633 else if(n[1] > 0) { bv_.
min_[1] = bv_.
max_[1] = d; }
635 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
638 if(n[2] < 0) { bv_.
min_[2] = bv_.
max_[2] = -d; }
639 else if(n[2] > 0) { bv_.
min_[2] = bv_.
max_[2] = d; }
647 template <
typename S>
652 Vector3<S> n = tf.linear() * s.
n;
654 generateCoordinateSystem(bv.
axis);
656 bv.
extent << 0, std::numeric_limits<S>::max(), std::numeric_limits<S>::max();
658 Vector3<S> p = s.
n * s.
d;
664 template <
typename S>
667 static void run(
const Plane<S>& s,
const Transform3<S>& tf,
RSS<S>& bv)
669 Vector3<S> n = tf.linear() * s.
n;
672 generateCoordinateSystem(bv.
axis);
674 bv.
l[0] = std::numeric_limits<S>::max();
675 bv.
l[1] = std::numeric_limits<S>::max();
679 Vector3<S> p = s.
n * s.
d;
685 template <
typename S>
696 template <
typename S>
699 static void run(
const Plane<S>& s,
const Transform3<S>& tf,
kIOS<S>& bv)
704 bv.
spheres[0].r = std::numeric_limits<S>::max();
709 template <
typename S>
715 const Vector3<S>& n = new_s.
n;
716 const S& d = new_s.
d;
718 const std::size_t D = 8;
720 for(std::size_t i = 0; i < D; ++i)
721 bv.dist(i) = -std::numeric_limits<S>::max();
722 for(std::size_t i = D; i < 2 * D; ++i)
723 bv.dist(i) = std::numeric_limits<S>::max();
725 if(n[1] == (S)0.0 && n[2] == (S)0.0)
727 if(n[0] > 0) bv.dist(0) = bv.dist(D) = d;
728 else bv.dist(0) = bv.dist(D) = -d;
730 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
732 if(n[1] > 0) bv.dist(1) = bv.dist(D + 1) = d;
733 else bv.dist(1) = bv.dist(D + 1) = -d;
735 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
737 if(n[2] > 0) bv.dist(2) = bv.dist(D + 2) = d;
738 else bv.dist(2) = bv.dist(D + 2) = -d;
740 else if(n[2] == (S)0.0 && n[0] == n[1])
742 bv.dist(3) = bv.dist(D + 3) = n[0] * d * 2;
744 else if(n[1] == (S)0.0 && n[0] == n[2])
746 bv.dist(4) = bv.dist(D + 4) = n[0] * d * 2;
748 else if(n[0] == (S)0.0 && n[1] == n[2])
750 bv.dist(6) = bv.dist(D + 5) = n[1] * d * 2;
752 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
754 bv.dist(6) = bv.dist(D + 6) = n[0] * d * 2;
756 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
758 bv.dist(7) = bv.dist(D + 7) = n[0] * d * 2;
764 template <
typename S>
770 const Vector3<S>& n = new_s.
n;
771 const S& d = new_s.
d;
773 const std::size_t D = 9;
775 for(std::size_t i = 0; i < D; ++i)
776 bv.dist(i) = -std::numeric_limits<S>::max();
777 for(std::size_t i = D; i < 2 * D; ++i)
778 bv.dist(i) = std::numeric_limits<S>::max();
780 if(n[1] == (S)0.0 && n[2] == (S)0.0)
782 if(n[0] > 0) bv.dist(0) = bv.dist(D) = d;
783 else bv.dist(0) = bv.dist(D) = -d;
785 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
787 if(n[1] > 0) bv.dist(1) = bv.dist(D + 1) = d;
788 else bv.dist(1) = bv.dist(D + 1) = -d;
790 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
792 if(n[2] > 0) bv.dist(2) = bv.dist(D + 2) = d;
793 else bv.dist(2) = bv.dist(D + 2) = -d;
795 else if(n[2] == (S)0.0 && n[0] == n[1])
797 bv.dist(3) = bv.dist(D + 3) = n[0] * d * 2;
799 else if(n[1] == (S)0.0 && n[0] == n[2])
801 bv.dist(4) = bv.dist(D + 4) = n[0] * d * 2;
803 else if(n[0] == (S)0.0 && n[1] == n[2])
805 bv.dist(5) = bv.dist(D + 5) = n[1] * d * 2;
807 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
809 bv.dist(6) = bv.dist(D + 6) = n[0] * d * 2;
811 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
813 bv.dist(7) = bv.dist(D + 7) = n[0] * d * 2;
815 else if(n[0] == (S)0.0 && n[1] + n[2] == (S)0.0)
817 bv.dist(8) = bv.dist(D + 8) = n[1] * d * 2;
823 template <
typename S>
829 const Vector3<S>& n = new_s.
n;
830 const S& d = new_s.
d;
832 const std::size_t D = 12;
834 for(std::size_t i = 0; i < D; ++i)
835 bv.dist(i) = -std::numeric_limits<S>::max();
836 for(std::size_t i = D; i < 2 * D; ++i)
837 bv.dist(i) = std::numeric_limits<S>::max();
839 if(n[1] == (S)0.0 && n[2] == (S)0.0)
841 if(n[0] > 0) bv.dist(0) = bv.dist(D) = d;
842 else bv.dist(0) = bv.dist(D) = -d;
844 else if(n[0] == (S)0.0 && n[2] == (S)0.0)
846 if(n[1] > 0) bv.dist(1) = bv.dist(D + 1) = d;
847 else bv.dist(1) = bv.dist(D + 1) = -d;
849 else if(n[0] == (S)0.0 && n[1] == (S)0.0)
851 if(n[2] > 0) bv.dist(2) = bv.dist(D + 2) = d;
852 else bv.dist(2) = bv.dist(D + 2) = -d;
854 else if(n[2] == (S)0.0 && n[0] == n[1])
856 bv.dist(3) = bv.dist(D + 3) = n[0] * d * 2;
858 else if(n[1] == (S)0.0 && n[0] == n[2])
860 bv.dist(4) = bv.dist(D + 4) = n[0] * d * 2;
862 else if(n[0] == (S)0.0 && n[1] == n[2])
864 bv.dist(5) = bv.dist(D + 5) = n[1] * d * 2;
866 else if(n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
868 bv.dist(6) = bv.dist(D + 6) = n[0] * d * 2;
870 else if(n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
872 bv.dist(7) = bv.dist(D + 7) = n[0] * d * 2;
874 else if(n[0] == (S)0.0 && n[1] + n[2] == (S)0.0)
876 bv.dist(8) = bv.dist(D + 8) = n[1] * d * 2;
878 else if(n[0] + n[2] == (S)0.0 && n[0] + n[1] == (S)0.0)
880 bv.dist(9) = bv.dist(D + 9) = n[0] * d * 3;
882 else if(n[0] + n[1] == (S)0.0 && n[1] + n[2] == (S)0.0)
884 bv.dist(10) = bv.dist(D + 10) = n[0] * d * 3;
886 else if(n[0] + n[1] == (S)0.0 && n[0] + n[2] == (S)0.0)
888 bv.dist(11) = bv.dist(D + 11) = n[1] * d * 3;
894 template <
typename S>
899 const Vector3<S> v_delta = Vector3<S>::Constant(s.
radius);
900 bv.
max_ = tf.translation() + v_delta;
901 bv.
min_ = tf.translation() - v_delta;
906 template <
typename S>
909 static void run(
const Sphere<S>& s,
const Transform3<S>& tf,
OBB<S>& bv)
911 bv.
To = tf.translation();
912 bv.
axis.setIdentity();
918 template <
typename S>
923 bv =
AABB<S>(tf * s.a, tf * s.b, tf * s.c);
1048 template <
typename BV,
typename Shape>
1049 void computeBV(
const Shape& s,
const Transform3<typename BV::S>& tf, BV& bv)
1051 using S =
typename BV::S;
1057 template <
typename S>
1061 tf.linear().setIdentity();
1062 tf.translation() = bv.
center();
1066 template <
typename S>
1067 void constructBox(
const OBB<S>& bv,
Box<S>& box, Transform3<S>& tf)
1070 tf.linear() = bv.
axis;
1071 tf.translation() = bv.
To;
1075 template <
typename S>
1076 void constructBox(
const OBBRSS<S>& bv,
Box<S>& box, Transform3<S>& tf)
1080 tf.translation() = bv.
obb.
To;
1084 template <
typename S>
1085 void constructBox(
const kIOS<S>& bv,
Box<S>& box, Transform3<S>& tf)
1089 tf.translation() = bv.
obb.
To;
1093 template <
typename S>
1094 void constructBox(
const RSS<S>& bv,
Box<S>& box, Transform3<S>& tf)
1097 tf.linear() = bv.
axis;
1098 tf.translation() = bv.
To;
1102 template <
typename S>
1106 tf.linear().setIdentity();
1107 tf.translation() = bv.
center();
1111 template <
typename S>
1115 tf.linear().setIdentity();
1116 tf.translation() = bv.
center();
1120 template <
typename S>
1124 tf.linear().setIdentity();
1125 tf.translation() = bv.
center();
1129 template <
typename S>
1130 void constructBox(
const AABB<S>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1133 tf = tf_bv * Translation3<S>(bv.
center());
1137 template <
typename S>
1138 void constructBox(
const OBB<S>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1141 tf.linear() = bv.
axis;
1142 tf.translation() = bv.
To;
1146 template <
typename S>
1147 void constructBox(
const OBBRSS<S>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1151 tf.translation() = bv.
obb.
To;
1156 template <
typename S>
1157 void constructBox(
const kIOS<S>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1161 tf.translation() = bv.
obb.
To;
1165 template <
typename S>
1166 void constructBox(
const RSS<S>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1169 tf.linear() = bv.
axis;
1170 tf.translation() = bv.
To;
1175 template <
typename S>
1176 void constructBox(
const KDOP<S, 16>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1179 tf = tf_bv * Translation3<S>(bv.
center());
1183 template <
typename S>
1184 void constructBox(
const KDOP<S, 18>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1187 tf = tf_bv * Translation3<S>(bv.
center());
1191 template <
typename S>
1192 void constructBox(
const KDOP<S, 24>& bv,
const Transform3<S>& tf_bv,
Box<S>& box, Transform3<S>& tf)
1195 tf = tf_bv * Translation3<S>(bv.
center());
Triangle stores the points instead of only indices of points.
Definition: triangle_p.h:48
Half Space: this is equivalent to the Planed in ODE. The separation plane is defined as n * x = d; Po...
Definition: halfspace.h:55
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
S lz
Length along z axis.
Definition: capsule.h:61
static void run(const Plane< S > &s, const Transform3< S > &tf, OBB< S > &bv)
Definition: utility-inl.h:650
S depth() const
The (AABB) depth.
Definition: kDOP-inl.h:216
S radius
Radius of the cylinder.
Definition: cylinder.h:58
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition: AABB.h:49
Center at zero point ellipsoid.
Definition: ellipsoid.h:48
S d
Planed offset.
Definition: halfspace.h:83
S width() const
The (AABB) width.
Definition: kDOP-inl.h:202
static void run(const Halfspace< S > &s, const Transform3< S > &tf, OBB< S > &bv)
Definition: utility-inl.h:360
Vector3< S > max_
The max point in the AABB.
Definition: AABB.h:59
Vector3< S > center() const
Center of the AABB.
Definition: AABB-inl.h:230
S lz
Length along z axis.
Definition: cylinder.h:61
void fit(Vector3< typename BV::S > *ps, int n, BV &bv)
Compute a bounding volume that fits a set of n points.
Definition: utility-inl.h:647
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.
Definition: kDOP.h:84
Center at zero point capsule.
Definition: capsule.h:48
void computeBV(const Shape &s, const Transform3< typename BV::S > &tf, BV &bv)
calculate a bounding volume for a shape in a specific configuration
Definition: utility-inl.h:1049
OBB< S > obb
OBB related with kIOS.
Definition: kIOS.h:72
S lz
Length along z axis.
Definition: cone.h:60
Center at zero point, axis aligned box.
Definition: box.h:48
S radius
Radius of the cone.
Definition: cone.h:57
Vector3< S > center() const
The (AABB) center.
Definition: kDOP-inl.h:237
Vector3< S > min_
The min point in the AABB.
Definition: AABB.h:56
Vector3< S > side
box side length
Definition: box.h:64
unsigned int num_spheres
The number of spheres, no larger than 5.
Definition: kIOS.h:69
Vector3< S > extent
Half dimensions of OBB.
Definition: OBB.h:68
Convex polytope.
Definition: convex.h:48
Infinite plane.
Definition: plane.h:48
Center at zero cylinder.
Definition: cylinder.h:48
Vector3< S > radii
Radii of the ellipsoid.
Definition: ellipsoid.h:61
S height() const
The (AABB) height.
Definition: kDOP-inl.h:209
S d
Plane offset.
Definition: plane.h:76
Matrix3< S > axis
Orientation of OBB. The axes of the rotation matrix are the principle directions of the box...
Definition: OBB.h:62
Center at zero cone.
Definition: cone.h:48
S radius
Radius of the sphere.
Definition: sphere.h:57
Vector3< S > n
Planed normal.
Definition: halfspace.h:80
Center at zero point sphere.
Definition: sphere.h:48
S radius
Radius of capsule.
Definition: capsule.h:58
Definition: utility-inl.h:123
Vector3< S > To
Center of OBB.
Definition: OBB.h:65
A class describing the kIOS collision structure, which is a set of spheres.
Definition: kIOS.h:48
Vector3< S > n
Plane normal.
Definition: plane.h:73
kIOS_Sphere spheres[5]
The (at most) five spheres for intersection.
Definition: kIOS.h:66
Oriented bounding box class.
Definition: OBB.h:51