# Bounding Volumes

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

## Recommended Posts

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 &lt;= radA + radB)

?

##### Share on other sites
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 on other sites
Because then you're comparing a vector type with a scalar type, which doesn't make sense, instead you need to be comparing with the vector's magnitude (squared for efficiency) which is a scalar.

Thanks