# Get intersected volume of two planes in 3D

I'm working on AABB - AABB collision response and I'm having trouble figuring one part out. My situation is as follows (see image).

I have a player AABB (blue) and an object which collides (brown). I've drawn a few faces for both AABB's. The player moves towards the cube and collides with two planes (colliding planes have their normal's drawn). These normals will be returned in the code in the 'normals' vector. I then check the opposing planes and try to get the volume of the intersected plane (right side of image).

I based my face detection algorithm on the following question : AABB - AABB Collision, which face do I hit?

The Two AABB's colliding (blue is Player AABB and brown is object) If I have multiple normals returned (which happens when two faces collide) I want to calculate the highest intersected volume between the collided faces and take that normal as the normal to base my collision response on (right side of image). It works for some faces but for the other half it doesn't work and I assume this has to do with change of vertex order which make my substractions pointless in some cases.

Is there some general way to calculate the volume of two intersecting planes in 3D that helps me resolve my response?

Code attempt for calculating highest volume between two (not working as it should):

functionThatDoesCollisionResponse
{
[...]
// Calculate size differences first
for(int i = 0; i < normals.size(); i++) // Normals is vector filled with all intersected plane normals.
{
Vector oppNormal = normals[i].Negative();
Plane pFace = this->GetPlaneFromNormal(player, oppNormal); // Returns plane with specified normal
Plane oFace = this->GetPlaneFromNormal(object, normals[i]);
sizeDifs.push_back(this->CalculateSizeDifference(pFace, oFace)); // Pushes differences of size in Vector for later calculation
}

// Don't take average but take highest intersected volume plane
GLfloat min = 9999999.99f;
Vector bestNormal;
for(int i = 0; i < sizeDifs.size(); i++)
{
GLfloat opp = sizeDifs[i].x * sizeDifs[i].y * sizeDifs[i].z;
if(opp < min)
{
min = opp;
bestNormal = normals[i];
}
}
[...]
}

Vector CollisionEngine::CalculateSizeDifference(Plane p1, Plane p2)
{
GLfloat xDif = p1.topLeft.x - p2.topLeft.x;
GLfloat yDif = p1.topLeft.y - p2.bottomLeft.y;
GLfloat zDif = p1.topLeft.z - p2.bottomRight.z;
return Vector(abs(xDif), abs(yDif), abs(zDif));
}