Transforming AABB's?

Miscellaneous Forums/General Discussion/Transforming AABB's?

I'm needing to grab Axis-Aligned Bounding Boxes for some objects, and since TrueVision3D's bounding box commands are apparently broken for global calculation, I'm writing my own. It doesn't seem like it will be hard to do, but possibly harder to do fast.

It seems to me that you just need to calculate the eight bounding points from the 2 points which define the original AABB, transform all eight points into whatever coordinate space I want ( in this case from local to global ) and then sift through all eight points to see where the bounds of a new AABB are.

But that's the slowest possibly way, obviously, so I'm wondering if there are optimizations which can be made in here.

You can transform the vector of half the dimensions to global space and make a cube. It won't be very accurate, but it will always enclose the local AABB.

I'm not sure what your asking to be honest but in B3d ...

;check point is inside aabb, assuming Pivot is the center and has oriention

tformpoint p\x , p\y , p\z, Pivot, 0

If abs( tformedx() ) < WidthOfBox and abs( tformedy() ) < HeightOfBox and abs( tformedz() ) < DepthOfBox
{Point is inside the box}
endif

Maybe helps, probably not, but if you explain yourself better then I can probably help.

Stevie

Leadwerks: Aha, good idea. The boundings need not be centered around 0,0,0 so I'll need to transform the center point too, but that's still a quarter of the points I'm doing now. Thanks!

Stevie: Well I'm not really getting my head around your answer either, so I guess that makes us even? :) Your answer seems to be for an oriented bounding box rather than axis-aligned, but perhaps I'm just not understanding you. Anyway, I have no need to calculate whether or not a point is inside it, I simply need to compute the boundings.

Anyway, I think Leadwerks' suggestion will work well for me.

And just to confirm that I implemented Leadwerk's suggested fix, and indeed it does work like a charm. Thanks again.