AABB to sphere

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

Recommended Posts

It is very easy to compute the bounding sphere to an AABB: - use center of box as sphere origin - use distance between center and a corner as sphere radius. Now my question is simply: is there a way to compute this same sphere, but without using a square root (distance calculation) ? Intuitively, I would say probably not, but I would like to be sure I'm not missing a trick or something... Y.

Share on other sites
nope. No way around it, I believe.

Share on other sites
The only thing I can think of is to represent a sphere in terms of the radius2, if you're using such a sphere for collision detection alone then that may well be suitable.

Share on other sites
If you assume the aabb is actually enclosed by a cube the size of your largest half axis, you should be able to multiply the largest half axis by the square-root of 3 and get a sphere radius that will enclose the cube. This may not be accurate enough for you if your aabb are far from being ideal cubes, but the sphere will surround the aabb.

If you have a unit sphere centered at the origin, an aabb that encompasses it will have a corner at (1,1,1), whose distance from the origin is sqrt(1*1 + 1*1 + 1*1) = sqrt(3), which since the half axii are 1, mean that a sphere bounding the cube equals the sqrt(3) times any of the half axii.

For non-cube aabb, taking a suggestion from a collision detection article a while back, whereby you divided the interacting variables by the half-axii to convert things from ellipsoid into unit-sphere space, multiplying your half-axii by the sqrt(3) will get you the relevant bounding ellipse instead. Dividing by the sqrt(3) will get you the enclosed sphere/cube or ellipse/aabb.

In 2d this would be the sqrt(2) instead.

I hope that makes sense.

- revel8n

[Edited by - Amadeus on June 16, 2008 1:35:20 PM]

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 12
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633723
• Total Posts
3013545
×