Centroid of object after linear transformations

315 Views Asked by At

I am developing a 3D renderer/model viewer from scratch in C++. In it, there are some transformations that require the center of the object(set of points) and as there are many objects with thousands of vertices, calculating the centroid after each iteration of the program would be costly.

So I was wondering:

If the center of an object, after any number of linear transformations would be the same as the original center affected by those transformations? (including rotation, translation in 4D coordinates).


1

There are 1 best solutions below

1
On BEST ANSWER

Yes, this is true.

Let $X\in \mathbb{R}^{4\times n}$ be the matrix that contains the (4D) coordinates of the vertices of the object.

The centroid $x_C$ can always be expressed as a certain convex combination of the vertices of the object, i.e. $x_C = Xv$ with $v=(\lambda_1\;\ldots\; \lambda_n)^T$ and $\sum \lambda_i = 1$, where $v$ is constant. $v$ depends only on the shape of the object but not on its position in the space.

Let $A\in \mathbb{R}^{4\times 4}$ be the matrix that represents your accumulated transformations.

Performing the transformations and then calculating the centroid is like calculating $(AX)v$, while calculating the centroid and then performing the transformations is like calculating $A(Xv)$. They are both the same according to the associative law of matrix multiplication.