# SVD and how to get two points on a 3D line from the representation of the line by means of two intersecting planes?

I have a 3D line represented by the intersection of these two planes

$a_1x+b_1y+c_1z+d_1=0$

$a_2x+b_2y+c_2z+d_2=0$

I need to compute two 3D points $P_1=(x_1,y_1,z_1)$ and $P_2=(x_2,y_2,z_2)$ belonging to the line and I have a reliable, robust and accurate SVD algorithm implementation in my software library.

My first idea is to solve the first plane equation for $x$:

$x=f_1(y,z)$

and then plug the $x$ into the second plane equation and solve it for $y$:

$y=f_2(z)$

Now I choose a value for $z_1$, for example $z_1=0$ and compute $y_1$ from $f_2(z_1)$ and $x_1$ from $f_1(y_1,z_1)$; I can also choose another value $z_2\ne z_1$ and compute in the same way $y_2$ and $x_2$. In this way I had to write a specific algorithm to compute the $P_1$ and $P_2$ coordinates and I cannot use the available SVD algorithm.

Then I had a look at Multiple View Geometry in Computer Vision, Second Edition by Richard Hartley and Andrew Zisserman where in section 3.2.2 Lines - Null-space and span representation they wrote that:

$W=\begin{bmatrix}x_1 & y_1 & z_1 & 1\\x_2 & y_2 & z_2 & 1\end{bmatrix}$

$W^*=\begin{bmatrix}a_1 & b_1 & c_1 & d_1\\a_2 & b_2 & c_2 & d_1\end{bmatrix}$

and

$W^* W^T=\begin{bmatrix}0 & 0 \\0 & 0 \end{bmatrix}$

and that I can go from $W^*$ to $W$ by means of SVD, thus I can use the available SVD algorithm. It is not clear to me how to use the SVD algorithm to solve the problem, can you explain it?

-

Take the SVD from your known $W^*$ to get $$W^* = USV^T$$ with the singular values in $S$ $$S =\begin{bmatrix}\sigma_1 & 0 & 0 & 0\\ 0 & \sigma_2 & 0 & 0\end{bmatrix}$$

To obtain $W$ then you want $W$ such that $$W^*W^T = USV^TW^T =\begin{bmatrix}0 & 0 \\0 & 0 \end{bmatrix}$$

Because $V$ is a unitary matrix, you can select from the last two rows. Say you have $$V^T = \begin{bmatrix} \mathbf{v}_1^T \\ \mathbf{v}_2^T \\ \mathbf{v}_3^T \\ \mathbf{v}_4^T \\\end{bmatrix}$$ then $$V^T\begin{bmatrix}\mathbf{v}_3 & \mathbf{v}_4\end{bmatrix}=\begin{bmatrix}0 & 0 \\ 0 & 0 \\ 1 & 0 \\ 0 & 1\end{bmatrix}$$ So that gives $$W^T = \begin{bmatrix}\mathbf{v}_3 & \mathbf{v}_4\end{bmatrix} K$$

Where $K$ is as desired since the final result is zero: $$U\begin{bmatrix}\sigma_1 & 0 & 0 & 0\\ 0 & \sigma_2 & 0 & 0\end{bmatrix}\begin{bmatrix}0 & 0 \\ 0 & 0 \\ 1 & 0 \\ 0 & 1\end{bmatrix}K = U\begin{bmatrix}0 & 0 \\0 & 0 \end{bmatrix}K =\begin{bmatrix}0 & 0 \\0 & 0 \end{bmatrix}$$

Now $K$ may be used to have your $1$ values in the positions you show them for $W$.$$W = K\begin{bmatrix}\mathbf{v}_3^T \\ \mathbf{v}_4^T\end{bmatrix}$$

-
Thank you! If I understood your answer, $K$ is a constant matrix (with an appropriate form), and I do not need to compute it, isn't it? This is because basically my solution is just $P_1=\mathbf{v}_3^T$ and $P_2=\mathbf{v}_4^T$ that I get from the SVD, am I right? And because if $P_1$ is a point on my line, $k_1\cdot P_1=(k_1\cdot x_1,k_1\cdot y_1, k_1\cdot z_1)$ will still be a point on my line. –  Alessandro Jacopson Mar 22 '13 at 8:11
yes. I was only considering that you had the ones in the last position for $W$. Any non-singular $K$ may be chosen for any reason that it can help with. You may not need to compute it for your application, correct. –  adam W Mar 22 '13 at 12:47