Least Squares Solution for the Closest 3D Point to a Set of Planes

geometryleast squaresplane-geometryregressionvector-spaces

I have a set of 2D planes in 3D space, each defined by a point on the plane and a normal vector to the plane (so vertically oriented planes are allowed). I need to find the point in 3D space that has the minimum sum of squared distances to all the planes. What's the right way to formulate this problem as a least squares regression?

(The regression is underspecified for fewer than 3 mutually intersecting planes.)

It would be even more ideal if I could use RANSAC to discard outliers, because the planes are unlikely to all intersect at a point.

Best Answer

The equation of any of the planes can be written as $$ \newcommand{x}{\mathbf x}\newcommand{v}{\mathbf v}\newcommand{c}{c} \x \cdot \v_i + \c_i = 0 $$ where $\x$ is the set of coordinates of a point on the plane, $\v_i$ is the normal vector to the plane, and $\c_i$ is a constant. You can find $\c_i$ by evaluating $-\x \cdot \v_i$ where $\x$ is set to the coordinates of the known point on the plane.

The distance from a point $\x$ to the plane is $$ \frac{\lvert\x \cdot \v_i + \c_i\rvert}{\lVert\v_i\rVert} $$

and the square of the distance is therefore $$ f(\x) = \frac{1}{\lVert\v_i\rVert^2} \left((\x \cdot \v_i)^2 + 2 c_i (\x \cdot \v_i) + c_i^2\right). $$

This comes down to a quadratic polynomial over the coordinates of $\x.$ Add together the polynomials from all planes and you still have a quadratic polynomial over the coordinates of $\x$, which is to be minimized.

If we represent the vectors by column vectors of coordinates, then $(\x \cdot \v_i)^2$ is $(\x^T \v_i)^2$ in matrix notation, and $$ (\x^T \v_i)^2 = (\x^T \v_i)(\v_i^T \x) = \x^T A \x $$ where $A = \v_i \v_i^T.$ So $f(\x)$ is a quadratic form, which may help.

Related Question