Given two rectangular parallelepipeds in $3D$ space, how would you compute the volume of their intersection? The orientations of the two rectangular parallelepipeds are not constrained in any special way. Each parallelepiped is described by a point $P$ that is a corner of the $parallelepiped$ as well as vectors $F$, $G$, and $H$ which represent the three mutually orthogonal edges that meet at point $P$.
[Math] Volume of the intersection of two rectangular parallelepipeds
geometry
Related Solutions
By linear coordinate transform you can simplify the problem to a unit n-sphere intersecting with an ellipse that is aligned with the axes (i.e. not rotated).
The simple case is where you have a intersection in one continuous area only (rather than one ellipse poking through the other, which is more complicated, and I will ignore this general case). In that simple case, the intersecting hyper-plane can be found similarly as in https://math.stackexchange.com/questions/162250/how-to-compute-the-volume-of-intersection-between-two-hyperspheres
You can compute the cap of the n-sphere as in that question. The remainder is the intersection of the ellipsoid with the hyperplane. I think it should be possible to apply another linear coordinate transform, and get another n-sphere cap for the second term.
I'd myself be interested in the details of this solution though.
Let $A$ be the matrix in question, writing $D(A) = \sqrt{\det(A^T A)}$ and $V(A)$ for the desired $n$-volume; we want to see that $D(A) = V(A)$. Note that the claim is easy if $m < n$, since the rank of $A^T A$ is bounded above by the minimum of rank $A$ and rank $A^T$, so we assume $m \ge n$.
Choose orthogonal matrices $P$ and $Q$ of sizes $m \times m$ and $n \times n$. Now $$D(PAQ) = \sqrt{\det((PAQ)^T (PAQ))} = \sqrt{\det(Q^T A^TA Q)} = \sqrt{\det(A^T A)} = D(A).$$ I claim that $V(PA) = V(A)$. Indeed, write $$A = (v_1 \; v_2 \; \dots \; v_n)$$ where the $v_i$ are columns. It is now possible to choose $v_i$ for $n+1 \le i \le m$ in such a way that $V(A) = |\det (v_1 \; v_2 \; \dots \; v_m)|$; in fact, take $v_{n+1}$ to be of unit length and orthogonal to the span of the columns of $A$, and then repeat. Now, since $P$ preserves inner products (and norms), $$V(A) = \left |\det (v_1 \; v_2 \; \dots \; v_m)\right| = \left|\det (Pv_1 \; Pv_2 \; \dots \; Pv_m)\right| = V(Pv_1 \; Pv_2 \; \dots \; Pv_n) = V(PA).$$ Now write $A = URW$ using $SVD$, where $U, W$ are orthogonal and $R$ is rectangular diagonal with non-negative entries. Then $$V(A) = V(U^T A) = V(RW) = V(R).$$ The last equality follows since $V(W) = 1$, and if the diagonal entries of $R$ are $d_1, \dots, d_n$, then the column vectors of $RW$ are $d_1$ times longer than $W$'s in the 1st dimension, $d_2$ times longer in the 2nd dimension, etc. Thus $V(A) = V(R) = D(R) = D(URW) = D(A)$, where $V(R) = D(R)$ comes down to checking the claim for $n$-cells with edges in the axes.
Best Answer
A workable way would be to clip all 6 boundary faces of each box against the boundary planes of the other, which leaves you with a bunch of convex faces that form the boundary of the intersection object. The actual volume of this object can be calculated by
$$ V = \frac{1}{3} \sum_{F_i \in Faces} \vec p_i \cdot \vec n_i A_i $$
in which $\vec p_i$ is a point on the face, $\vec n_i$ is the unit face normal and $A_i$ is the area of face $F_i$. Take care to keep the orientation of the faces consistent, however.