Jump to content
  • Advertisement
Sign in to follow this  
Ysaneya

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!