Jump to content
  • Advertisement
Sign in to follow this  

Collision Normal - AABB - sphere

This topic is 4136 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

Hello all! For a game I'm programming I would need the collison normal of a bounding-sphere with an Axis-aligned Bounding Box. The collision normal should be a simple vector (Up, Down, Left, etc...) in the case of a collision of the sphere with a face of the AABB or a more exact normal if the sphere collides with an edge or even a simple point. Now I can't find any resources in the net for this particular problem. I don't even know how I could check if the sphere collides only with an edge or a point. Could you guide me to the right direction?

Share this post

Link to post
Share on other sites
What Intersection algorithm do you use? In case you perform a triangle intersection check, you're likely to receive the barycentric coordinates of the point on the triangle. Use them to compute the point of intersection and get
your collision normal with "collisionNormal = Sphere.Center - PointOfIntersection"... You might want to normalize it though.
That's all I can say with what you've posted so far.

Good luck!


<edit> Do you want to take movement into account?</edit>

Share this post

Link to post
Share on other sites
The collision normal of a sphere with anything is always along a line from the centre of the sphere to the contact point - along a radius.

As for whether it collides with a corner, edge or face this is determined by the location of the sphere's centre. One way of looking at it is as follows:

Suppose the box is defined by

x1 < x < x2
y1 < y < y2
z1 < z < z2

and the sphere is at (X, Y, Z)

Simply count how many of the following are true

x1 < X < x2
y1 < Y < y2
z1 < Z < z2

If none are true the sphere hits a corner. If one is true the sphere hits an edge. If two are true the sphere hits a face (if three are true the sphere is inside the box, which is case you probably want to exclude).

More formally the planes x = x1, x = x2 etc. divide the space into Voronoi regions, of which this is an application. You can work them out for other polygonal bodies, though the maths quickly gets a lot more complicated.

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!