0

If a 3D box(a bounding box) knows it's position, it's width, it's height and it's depth, what would be the most efficient(can run in real time) way of detecting if a 3D co-ordinate is inside that box?
I already have something in place to check for it but I am wondering if there is anything more efficient,

vPosition is the position of the 3D Coordinate
GetPosition( ) returns the position of the 3D box

bool CBoundingBox::IsInside( VEC vPosition )
{
	return ( ( vPosition.x > GetPosition( ).x && vPosition.x < GetPosition( ).x + m_fWidth ) ||
	( vPosition.y < GetPosition( ).y && vPosition.y > GetPosition( ).y - m_fHeight ) ||
	( vPosition.z > GetPosition( ).z && vPosition.z < GetPosition( ).z + m_fWidth ) );
}

Edited by tomtetlaw: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by firstPerson
0

at the moment they aren't, and i don't think i will, i might just rotate the model inside the box and always keep the box the same rotation.

0

If the bounding box does not rotate, then I'm thinking you can
compare the distance between the box. Just like you would in a circle to
circle collision test. What do you think. I can't really test it out, but I am guessing you can.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.