Collision Normal - AABB - sphere

Started by
1 comment, last by johnb 16 years, 10 months ago
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?
Advertisement
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>
--I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
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.
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement