# Collision between a point and a box

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

## Recommended Posts

I'm currently working on a 3d game and have been looking into and working on the collisions. I have collision of two OBBs working using the separating axis theorem. But I also need to be able to check if a single point lies within a OBB, obviously I could use SAT and give my OBB representing the point a half size of 0 but I was wondering if the is a different more efficient way of doing this calculation?

Any suggestions would be greatly appreciated, even just the names of some methods.

##### Share on other sites
1. Transform the point into the local space of the box.

2. See if the (transformed) point coordinates are in the range [-extent, extent] for each of the cardinal axes.

##### Share on other sites
thanks for the advice, I kinda have it working can rotate my box through the Y (up) axis and the collision detection works and well as when there is no rotation at all, the problem I have is when I rotate X or Z axis. Not sure if I'm doing everything correctly.

1. Transform the point to local space: Am I right in thinking you do this by multiplying the point by the inverse world matrix of the box.

2. check agains the -extended and extended cardinal axes, this is probably where I'm going wrong. Do I need to do something special when the box is rotated???

##### Share on other sites
Quote:
 Transform the point to local space: Am I right in thinking you do this by multiplying the point by the inverse world matrix of the box.
Yes.
Quote:
 Do I need to do something special when the box is rotated???
No.

If it's not working as you expect, you might post your code.

##### Share on other sites
Well with a little digging i've worked out what it is :).

The box when getting rotated in world around the X and Z isn't rotated around the boxes center it getting rotated around the bottom of the box, cos the boxes are constructed from data from Max. so I'm guessing instead of checking if it between -extend and extend for X and Z I just need to check if it inbetween 0 and extend *2?

cos this is part of a group project i'm working on so if i go changing the way the boxes read in from max it will break other areas of the game.

##### Share on other sites
sorry I meant check from 0 to extend*2 for Y axis cos obviously the Y values in local space will need to be worked out from the bottom not the center and from -extend to extend for X and Z axes

##### Share on other sites
Correct, if your boxes are not centered at the origin you'll have to adjust your code accordingly.

##### Share on other sites
thanks for all the help its all working brilliantly now :D :D

1. 1
2. 2
Rutin
25
3. 3
4. 4
JoeJ
18
5. 5
gaxio
11

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002215
×