[Math] Plane fitting using SVD normal vector

svd

I am trying to fit the plane using SVD. The algorithm that I am using is following:

  1. From each point subtract centroid
  2. Calculate SVD
  3. Find normal as 3rd column of matrix $U$

I have 7 points to fit. So matrix $A$ is $7\times3$. Matrix U is $7\times7$. My problem or question is : I assume that normal vector in 3d space are consist of 3 numbers. Matrix $U$ is $7\times7$. If I take 3rd column of matrix $U$ then I have $7$ numbers. I don't know which 3 numbers from these 7 numbers are my normal vector. Thank you very much for your answers.

Best Answer

The SVD decomposition of $A \in \mathbb{R}^{7 \times 3}$ is as follows:

$A = U \Sigma V^T$

where $U$ is a $7 \times 7$ orthogonal matrix, $V$ is a $3 \times 3$ orthogonal matrix, and $\Sigma$ is a $7 \times 3$ "diagonal" matrix. The meaning of each matrix is:

  • Columns of $U$ (Left singular vectors): They span the space of columns of $A$ (collections of $x$, $y$ and $z$ coordinates)
  • Columns of $V$ (Right singular vectors): They span the space of rows of $A$ (3D points)
  • Diagonal of $\Sigma$: Singular values linked to each left/right singular vector. If there is some zero singular value, its singular vector won't be required to span the space of $x$, $y$ and $z$ coordinates or 3D points.

In this case, since all 3D points are supposed to be in a plane (2 dimensional space) the minimal basis which spans them will have two components, thus, there will be only 2 singular values different to zero. If you write: $$ U = (u_1 \dots u_7)$$ $$ V = (v_1 \dots v_3)$$ $$ \Sigma = diag(\sigma_1, \sigma_2,\sigma_3)$$ With $\sigma_3 = 0$

  • Vectors $\{u_1,u_2\}$ will span the collection of $x$, $y$ and $z$ coordinates
  • Vectors $\{v_1,v_2\}$ will span the collection of 3D points, which you are interested in. The third vector, $v_3$ associated to $\sigma_3 = 0$, will not be included in that plane, but normal to it.

What you are looking for is $v_3$

Related Question