# How do I determine the collision normal in an axis aligned bounding box collision?

I have a 3d moving box and a stationary box. I can detect collisions ok but now I would like to slide the moving box against the stationary box as a collision response. For this I need the normal of the face that collides with the moving box. Does anyone know how I figure this out? It doesn't seem like the collision test gives me this information. Any help is appreciated.

• The collision normal and the normal of the colliding face are different things. The collision normal depends on the subtracted velocities of the colliding objects. Whereas calculating the normal of a face is shown in Valkea's answer. For a proper collision response you will need both. – Maik Semder May 30 '11 at 10:04

In order to calculate the normal to a plane (the collided AABB face) you need:

• 3 points of this plane (2 non parallel edges).
• The cross product of two edge vectors of this plane (usually from the same point of origin).

This will produce a vector perpendicular to this plane (but a plane have 2 sides).

Here is an example of how to calculate the cross product.

Let A, B, C and D be the four points of your AABB collided side.

[B]---(c)
|     |
[A]---[D]


If we use ABC, then the normal to the plane is

ADxAB (if we want a normal pointing out of the screen)
ABxAD (if we want a normal pointing inside the screen)


(it's just because our example is facing the screen, if the plane is seen from left side, the fist normal will point right and the second will point left)

As you can see the order in which you take the points will impact the side the normal will point to. That's why developers usually store their points in a specified order (clockwise or counter-clockwise, but the same for all faces) so they know in which order to use them.

See this on more details now:

AB = [ Bx-Ax, By-Ay, Bz-Az ]
AD = [ Dx-Ax, Dy-Ay, Dz-Az ]


Here is how to get the first normal

ADxAB = [ ADx, ADy, ADz ] X  [ ABx, ABy, ABz ]


And here come the second normal pointing to the other side

ABxAD = [ ABx, ABy, ABz ] X  [ ADx, ADy, ADz ]


If you replace the ABx, ABy, ABz etc. values with the differences calculated just before (Bx-Ax, By-Ay, Bz-Az etc.) the cross products you will get the normal vectors.

• I have a min and a max. How do I calculate the normal with those – user116458 Jun 18 '18 at 9:54