Jump to content
  • Advertisement
Sign in to follow this  
evanofsky

simple box and point- but with a new twist

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to know how to determine if a point is inside a box. A *ROTATED* box. I know how to do it with one aligned to the X, Y, and Z axises (I forget the plural for axis), but not if it's rotated. Your help would be much appreciated. :)

Share this post


Link to post
Share on other sites
Advertisement
that should be plenty fast. if you use matrices, all you have to do is use the transpose of the orientation matrix of the box. Else, you have to check slabs, project the point along the face directions, ect... so in all pretty much the same.

Share this post


Link to post
Share on other sites
One other thing: if you're really worried about the cost of the inverse transformation, you can defer the dot products until they're absolutely needed, like this:


bool OBB::IntersectPoint(const Vector3& p) const
{
Vector3 tp = p - m_pos;

for (int i = 0; i < 3; ++i)
if (fabsf(tp.Dot(m_axis)) > m_extents)
return false;

return true;
}



A minor optimization, but an easy one to make.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!