# Oriented Bounding Box

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/05/2003 at 10:07, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   8.100
Platform:    Mac  ;
Language(s) :   C.O.F.F.E.E  ;

---------
Is there any in-built routine to calculate if the oriented Bounding Boxes of two objects intersect?
With oriented bounding boxes I mean the bounding boxes that are around the objects when they are oriented by 0,0,0 but that are rotated when the object is rotated too. Is this clear? ;-)
Thank you very much in advance.

Rui Batista

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/05/2003 at 13:43, xxxxxxxx wrote:

No. (And especially not in C.O.F.F.E.E... ;-)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/05/2003 at 03:14, xxxxxxxx wrote:

Ok, back to my net search :-(
By the way, when will COFFEE get an overhaul?

Rui Batista

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 16/09/2004 at 19:03, xxxxxxxx wrote:

I'd like to hear the answer to that one myself Rui.  Anybody?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/09/2004 at 06:55, xxxxxxxx wrote:

Take the object/hierarchy points (GetPointCount() and GetPoints()) and determine the default Bounding Box. The points retrieved from objects are not transformed and therefore represent the untransformed object.

Once you have the Bounding Box points, use object->GetMg() and apply it to its points (assuming the use of a PointObject for the Bounding Box) :

``````
var mat = object->GetMg();
for (i = 0; i < 8; i++)
bndBox->SetPoint(i) = mat->GetMulP(bndBox->GetPoint(i));
``````

This will transform the points to be oriented similarly to the object.

Then perform intersection tests as usual. General 3D intersection tests are somewhat complicated (as compared to axis-aligned bounding box ones). You will need to test for volume-volume intersection. Check out Graphics Gems and Game Programming Gems for solutions.

Robert

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/09/2004 at 09:00, xxxxxxxx wrote:

Just thought to mention that if you only calculate an axis-aligned bounding box on the objects' transformed points (using Mg), you can use the simple method of intersection testing, at least a first elimination test. This method quickly eliminates objects that in no way intersect.

It is just a matter of determining the 'minimum' and 'maximum' values on each axis (XYZ), and testing thusly:

if ((obj1minX < obj2minX) && (obj1maxX < obj2minX)) // no intersection
else if ((obj1minX > obj2maxX) && (obj1maxX > obj2maxX)) // no intersection
else if ((obj1minY < obj2minY) && (obj1maxY < obj2minY)) // no intersection
else if ((obj1minY > obj2maxY) && (obj1maxY > obj2maxY)) // no intersection
else if ((obj1minZ < obj2minZ) && (obj1maxZ < obj2minZ)) // no intersection
else if ((obj1minZ > obj2maxZ) && (obj1maxZ > obj2maxZ)) // no intersection

// otherwise there is a possible intersection - definite bounding box intersection

Robert