Find the best fitting plane given n points that goes through the origin

47 Views Asked by At

My Problem

I need to find the plane which best fits a given number of points (at least 3) and that must contain the origin. I'm supposed to do this with the least squares method, but i can also use something else. I got it working for some cases by using the SVD to compute the pseudoinverse. To explain my notation: the given points are $p_1,...,p_n$ and the $x$-coordinate of the point $p_i$ is denoted by $p_i^x$. The equation of the plane is of the form $z = rx + sy$, which goes through the origin for any $r,s \in \mathbb{R}$.

My approach

My basic idea is $Ax = b$ (where $x$ is the vector that contains the paramters $r$ and $s$ and $A$ and $b$ are defined down below).

I defined the matrix $A$ like the following : $$ A = \left(\begin{matrix}p_1^x & p_1^y \\ p_2^x & p_2^y \\ \vdots & \vdots \\ p_n^x & p_n^y\end{matrix}\right)$$ Now i took the pseudoinverse of $A$ and multiplied it with the vector $b$, where $b$ is: $$b = \left(\begin{matrix} p_1^z \\ p_2^z \\ \vdots \\ p_n^z\end{matrix}\right)$$ The result of this a vector with the parameters for the plane $z = r\cdot x + s\cdot y$: $$\left( \begin{matrix} r \\ s\end{matrix}\right) = A^+b$$ (where $A^+$ is the pseudoinverse). As mentioned this works sometimes, but i found an example where it doesn't work: $$p_1 = \left(\begin{matrix} 5 \\ 5 \\ 5 \end{matrix}\right) \qquad p_2 = \left(\begin{matrix} 6 \\ 6 \\ 3 \end{matrix}\right) \qquad p_3 = \left(\begin{matrix} 4 \\ 4 \\ 7 \end{matrix}\right)$$ My methods yield the equation $z = 0.461038x + 0.461038y$ (rounded). But the plane $z = 0.5x + 0.5y$ would be better because it minimizes the distances even more. I constructed this example myself to test, if my method is working.

Question

What's wrong with my method? What do i have to change? Or should i use another approach and if so, how?