Sign in to follow this  
DanEE

Collision Normal - AABB - sphere

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!

Martin

<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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this