Advertisement Jump to content
Sign in to follow this  

Rotated box collision with a point

This topic is 3971 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've got a 3D box in game that can be rotated about any axis and I was wondering about the best method for collision detection with that and a point in the world. I've read up about the separating-axis test and I could do that, but is there another way? I'm only doing collisions with a single point so it seems a full implementation of the SAT would be overkill. Any suggestions would be greatly appreciated.

Share this post

Link to post
Share on other sites
I had to do this the other day, but only in 2D. Maybe it could be extended to 3D? I gotta go so I have to write this up quick.

I rotated the point around to where it would be on the unrotated collision box, and then tested against the unrotated collision box. Here's how I did it


ul = upper left corner of collision box
lr = lower right corner of collision box
theta = current angle sprite is facing
position = position of sprite (vector)
point = point to test (vector)

Then calculate:

P(vector) = position - point
alpha = atan(P.y/P.x)
beta = alpha - theta
r = sqrt( P.x*P.x + P.y*P.y)

Then the rotated point:

R = <r * cos(beta), r * sin(beta>

Finally test:

if (R.x > ul.x && R.x < lr.x &&
R.y < ul.y && R.y > lr.y ) {
} else {

It helps to draw that on a whiteboard or something. Hope that gives you some ideas

Share this post

Link to post
Share on other sites
Is the 3D box moving? Is the Point moving?

If the box is just rotating and the point is stationary then make the box stationary and the point rotating. You'll notice it forms a circle. A circle to plane intersection test can be done. You'll get 0,1,2 or infinite intersection points. I'm not sure what the algorithm is though for the test, but it does exist.

Okay once you have the intersection points you can find the angles between them and which one is the first intersection point. This can then give you the exact time T between 0 and 1 when the intersection happened.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!