   OBB Algorithms
  Are there any algorithms that, given a set of points, can optimally wrap an OBB around it, so that space is not wasted?   
  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.   ;  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.   ;  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.pdfIf 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];  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.   ;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.   