# How to use PCA to reconstruct 3D Mesh？

Given a set of human body mesh {S_i}, for each S_i, the points are N*3, we can do PCA on that. We can use PCA to reduce the dimension of {S_i}, for example to k dimension. Let the main direction of PCA be [D1, D2, ..., Dk], then the body geometry can be represented by S = W1 * D1 + W2 * D2 + ... + Wk * Dk, where W = [W1, W2, ..., W3] is the weights.

But how can we get the weight W of one specific mesh S_i in {S_i}?

Given a matrix $$D \in \mathbb{R}^{3N\times k}$$ where each column is normalized $$D_i$$, You can get $$W = D^TS_i$$, and later it can be used to reconstruct the shape with $$S_i = DW$$ (With some error if you truncated some basis). The acquisition of weights is equivalent to calculating dot products between each PCA basis and $$S_i$$. What is done here is you project $$S_i$$ onto each orthogonal basis $$D_i$$, and calculate the length of the projected vector, so you are basically calculating the required contribution of each basis to construct the given $$S_i$$.
If you are using unnormalized PCA basis, you can decompose the unnormalized PCA basis matrix into a diagonal matrix an an orthonormal matrix (Say, $$\Lambda D$$), then use a similar approach to obtain the contribution of each basis. In this case, you'll have to use $$\Lambda^{-1}D^T$$ instead of $$D^T$$.