Sign in to follow this  
marius1930

Bounding Volumes

Recommended Posts

marius1930    119
Why does every article about bounding volumes mention using "the squared sum to avoid using square root" when calculating the distance? For a sphere, what would be wrong with a simple
if (locA - locB <= radA + radB)
?

Share this post


Link to post
Share on other sites
Cypher19    768
Because LocA and LocB (and their difference) are 2D, or 3D vectors, with x, y, and z components. The radius of the spheres are 1D, so you need some meaningful way to convert those vectors from [2|3]D to 1D. One way is to use pythagorean's theorem, a^2+b^2=c^2. For a 2D vector, the x component would be the value a, the y component would be the value b. To solve for c, you would do sqrt(a^2+b^2). Note that c is the length of the 2D vector, so you can now compare c to the radius of the sphere to. The reason why the square radius can be done is because, given two variables a and b with the inequality a > b, then a^2 > b^2 is also true.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this