Trying to make life worth

Sunday, December 30, 2018

How to determine whether the two Bounding boxes intersect or not ?

Let's assume we two Bounding Box A and B.  Proof is by contradiction. Any one of four conditions guarantees that no overlap can exist:
  • Cond1. If A's left edge is to the right of the B's right edge, - then A is Totally to right Of B
  • Cond2. If A's right edge is to the left of the B's left edge, - then A is Totally to left Of B
  • Cond3. If A's top edge is below B's bottom edge, - then A is Totally below B
  • Cond4. If A's bottom edge is above B's top edge, - then A is Totally above B
  • Cond5. If A's front edge is below B's bottom edge, - then A is Totally below B
  • Cond6 If A's back edge is above B's top edge, - then A is Totally above B
So condition for Intersect is
Cond1 && Cond2 && Cond3 && Cond4 && Cond5 && Cond6
Intesect Consdition: ((b_xmax >= a_xmin) && (b_xmin <= a_xmax) &&
            (b_ymax >= a_ymin) && (b_ymin <= a_ymax) &&
            (b_zmax >= a_zmin) && (b_zmin <= a_zmax))

No comments:

Post a Comment