# Sphere diameter and boundingSphere radius doesn´t match

Hello everyone. I am creating my own collision algorithms and noticed that some values are not exactly what I was expecting. Seems like a bug.

I created a sphere and was expecting that it’s boundingSphere had the same (or at least a close) value.

The sphere has: `diameter = 1` but the `boundingInfo.boundingSphere.radius = 0.8660254037844386`

Seems to be out by a factor of sqrt(3)

1 Like

Hello! I understand where the confusion comes from, but the boundingSphere is actually bigger than what you’re thinking, as its constructed directly from the minimum and maximum: Babylon.js/boundingSphere.ts at master · BabylonJS/Babylon.js (github.com). In this example, the min is (-0.5,-0.5,-0.5) and max is (0.5,0.5,0.5), when you get the distance between these two and half it, you’ll see it matches the 0.86 radius 1 Like

Sorry but (0.5, 0.5, 0.5) - (-0.5, -0.5, -0.5) = (1, 1, 1)

Half this and you get (0.5, 0.5, 0.5)

It’s distance, so sqrt((0.5 - (-0.5))^2 + (0.5 - (-0.5))^2 + (0.5 - (-0.5))^2) = 1.73 3 Likes

This may help debug and understand what’s going on Drawing Bounding Boxes | Babylon.js Documentation

EDIT: To be clear, as @carolhmj mention, the results seem correct, it’s just that the corners of the cube will stick out of the sphere and you’re comparing a diagonal that is larger than the diameter of the sphere. If you compared the distance at the middle point of the cube faces, you’d get the same as the sphere

1 Like

Sorry you are right its across the diagonal not just the difference.

3 Likes

Thank you @carolhmj makes sense now!