# OBB Algorithms

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

## Recommended Posts

Are there any algorithms that, given a set of points, can optimally wrap an OBB around it, so that space is not wasted?

##### Share on other sites
If you aren't planning to do this at runtime, it may be easiest to rotate your model around the y axis, such that every point gets a turn to be in the x direction. Then you could keep the configuration that has the least area for an axis-aligned square. Then clamp the top and bottom to your maximum and minimum.

Optimizing beyond that is not likely to yield any benefit, but will cost significantly more.

##### Share on other sites
Granted, an AABB is faster to calculate and use, but I'm not looking to wrap my object in an AABB. I'm trying to figure out how to orient an OBB around my object so it is most optimal.

##### Share on other sites
there is, it is used by the RAPID collision detection library. It's using the covariance matrix to find the vertex distribution. It's usually best to use the convex hull of the object you try to bound, instead of the object itself (so only the vertex at the periphery of the object will affect the bounding box).

http://www.itu.dk/courses/MEP/E2006/Lectures/lectures/collision2.pdf

If you don't fancy all the maths, and want a simple solution that is very very slow, you can take the convex hull of the object you are interested in, the cente of the bounding box will be the centre of the convex hull, and each axis of the bounding box will align with either a face, an edge, or a vertex.

by aligned, I mean :

1) use face normal as an axis for the bounding box.
2) take the closest point on edge from the centre, and use direction as axis.
3) take vector(vertex - centre), and use direction as axis.

Did I say slow?

[Edited by - oliii on April 29, 2009 11:09:37 AM]

##### Share on other sites
I don't mind it being very slow, because I will calculate this only once - during loading. Rotations and Scaling can be applied to the OBB after the fact without having to recalculate the OBB.

##### Share on other sites
Quote:
 Original post by RealMarkPGranted, an AABB is faster to calculate and use, but I'm not looking to wrap my object in an AABB. I'm trying to figure out how to orient an OBB around my object so it is most optimal.

If your object is optimized for the least area when you have rotated it by R, then you can rotate the AABB by R-1. The AABB, having been rotated, is no longer axis-aligned, but has been oriented to the model.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633676
• Total Posts
3013279
×