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

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

Martin

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

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

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 10
• 12
• ### Forum Statistics

• Total Topics
632569
• Total Posts
3007121

×