# OBB Intersection Tests

This topic is 2646 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all,

I'm implementing a few different OBB intersection tests (mainly ray/OBB and OBB/OBB for now). I have implemented two versions of ray/OBB intersection tests.

One is from Real Time Rendering which uses a Slabs Method.
The other is from David Eberly's book which uses a 6 separating axes test.

I have both algorithms working but I have a question I am hoping someone may be able to shed some light on. I am having trouble finding documentation that talks about how to handle OBB's that exist in a game engine (i.e. world space). The OBB may undergo translation, rotation, scaling, etc, which are all baked into the modelMatrix. These algorithms assume an OBB with unit vectors. Thus in order for these algorithms to work we must convert the axes of the OBB to unit vectors.

Here is my solution to this problem:

To convert an OBB center C to world coordinates, simply multiply it by the objects modelMatrix. Easy enough.

To convert the axes of the OBB to world space we take the 4x4 modelMatrix and convert it to an upper 3x3 modelMatrix (i.e. rotationMatrix), and multiply the axes by this matrix. Next we normalize the vectors. However, we must also change the values of the extents (or half lengths) since we have normalized the vectors. I do this by taking the inverse of the value used to normalize the vectors and multiply the extents by that.

Example:
len = Math.sqrt(axisU.x*axisU.x + axisU.y*axisU.y + axisU.z*axisU.z)
len = 1/len
axisU.x = axisU.x*len
axisU.y = axisU.y*len
axisU.z = axisU.z*len
extentU = extentU*(1/len);

and repeat for the other 2 axes/extents.

Then we can go on our marry way implementing the algorithms with unit vectors.

I am not a math ninja like Mr. Eberly and I'm not sure if this is the most effecient way of doing things. Obviously for intersection tests, having effecient algorithms is imporant. I was hoping someone may be able to offer some advice on my implementatation and how to handle OBB's combined with a modelMatrix.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633271
• Total Posts
3011160
• ### Who's Online (See full list)

There are no registered users currently online

×