# simple box and point- but with a new twist

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

## 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 on other sites
if you know the rotation of the box, you can inverse rotate the point, then check as usual.

##### Share on other sites
Hmm, I'm surprised I hadn't thought of that; I was hoping there was a faster way.

##### Share on other sites
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 on other sites
okey-dokey. Thanks for the replies!

##### 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.

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633350
• Total Posts
3011473
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!