As the title says, I want to compute the root mean square distance between two n-dimensional simplices. Say I have two surfaces $S$ and $S'$, the mean error is $ d_m(S,S') = \frac{1}{|S|} \int\int_{p \epsilon S} d(p,S')dS\,. $ where $|S|$ denotes the volume of $S$ and $d(p,S')=\underset{p' \epsilon S'}{\text{min}}||p-p'||_2 $. The root mean square error is the $ d_{rmse}(S,S')=\sqrt{ \frac{1}{|S|} \int\int_{p \epsilon S} d(p,S')^2dS\ },. $
Say I have a triangle $T_{i,j}=(x_{i,j},x_{i+1,j},x_{i,j+1})$ and associated errors $e_{i,j}, e_{i+1,j}$, and $e_{i,j+1}$. According to this paper, If we linearly interpolate between the error values, the integral of $e^2$ is $ \frac{|T_{i,j}|}{6}[e_{i,j}^2 + e_{i+1,j}^2 + e_{i,j+1}^2 + e_{i,j}e_{i+1,j}+ e_{i,j}e_{i,j+1} + e_{i+1,j}e_{i,j+1}] $
So my questions are (1) How is the third formula above derived? (2) how would I extend this to $n$-dimensions.
Edit I thought an image might help
The bottom triangle is $T_{i,j}=(x_{i,j},x_{i+1,j},x_{i,j+1})$, and the top triangle is a vertical distance of $e_{i,j}, e_{i+1,j}$, and $e_{i,j+1}$ from each point. The mean error would be the volume between the triangles. I don't know what the root mean square error is graphically.
Edit2 Forgot to stay that the error is linearly interpolated. Thanks, joriki.