Bounding box not axis aligned

I need an inside test for an area which is rotated. This area is represented by a plane.
I’ve tried using Box3 and Box2, applying scale, rotation and position of the mesh, but it seems that the box is always axis aligned.
Do I need to write a manual function or is there a way to have the Box not axis aligned?

const clone = myPlane.clone()
clone.applyQuaternion(scene.quaternion) // apply also scene rotation if any
const box = new T.Box3().setFromObject(clone)
scene.add(new T.Box3Helper(box, 0xFF00FF))

image

Yes this is how “axis-aligned bounding boxes” work. Box3 should actually be renamed to AABB3 and Box2 to AABB2. I’m not going to explain AABB since existing literature extensively discussed this topic. Just give google a try.

Anyway, you need a completely different type of bounding volume that allows rotation (e.g. an oriented bounding box or OBB). However, proper implementations are complex and often require the computation of a convex hull first.

1 Like

Mm I see, I need only the 2-dimensions check, so probably an inside polygon test is sufficient. Thanks!