Derivation of the covariance matrix for OBB construction

Each triangle k on the surface of the geometry can be
parameterized as

, where s ≥ 0, t ≥ 0, s + t ≤ 1

Let ,

Suppose we sample the area of this triangle k infinitely
densely, i.e. the infinitely small area is

Then, the area of triangle k can be computed as

Let

The total surface area of the geometry is the sum of the
surface area of all triangles that make up the geometry, i.e.

, where n is the number of triangles.

The covariance matrix is computed as

, where

Therefore,

Now evaluating the portion of the expression

Evaluating each term, we get

Expanding and summing up the terms, we get

Grouping these terms, we get

Note the centroid of each triangle is

, then the quantity is

Substituting  into the result,
we have the following

Putting this back into our original expression

So,

, where