Bounding Box size calculation

I’m working on a QuadTree implementation and levereging the BoundinBox class. I’m a bit baffled by the `extendSize` property, and I think my understanding might be off?

Let’s say we define a BoundingBox with:

• min: 0, 0, 0
• max: 1000, 0, 1000

I would expect the following:

• center 500, 0, 500
• size 1000, 0, 1000 ??

But at the moment the size is 500, 0, 500 - and looking at the code it does seem correct:

Any idea why the size would be 500 when I would expect a side size (in the case of a rectangle, or square) - to be 1000?

My math skills are not great, but I’d like to try to understand exactly why size is defined as (max - min) / 2.

Thanks!

Hi.

extendSize is a distance from the center of the box to it’s sides (x, y ,z)

So basically that’s W/2 x H/2 x D/2

If you want to get W x H x D you need to multiply each of these by 2. So something like
extendSize.scale(2)

Basically extendSize being 500, 500 in that case is the expected result.

3 Likes