1

This is slightly related to a recent post of mine. If I am dealing with three-dimensional Cartesian coordinates and have at least three points, how can I easily tell if the best-fit plane to the data points is vertical (or near-vertical) in the $z$ dimension?

My concern is that I have many sets of points and would like to fit a plane to each. In many cases, this is no issue. However, when the points lie on a plane that is vertical, I cannot fit a plane of the form $ax+by+c=z$ (just as I wouldn't be able to fit vertical points in the $xy$-coordinate system with an equation $y=mx+b$). I would like to automatically identify these instances but am not sure the best way to do so.

The very naive solution is to say that if two points have the same $x$ and $y$ coordinates, then the points lie on a vertical plane, but this is a very bad assumption because that one point could be an outlier in an otherwise horizontal plane (for instance). Note that I do not have the equation of the plane in advance, just the data points.

Argon
  • 183

2 Answers2

1

Consider three points with coordinates $\vec v_i=(x_i,y_i,z_i)$ with $i=1,2,3$. The obvious step for your problem would be to find the normal to this plane. You can do that by using the cross product $(\vec v_1 -\vec v_0)\times (\vec v_1 -\vec v_0)$. You can now look at the $z$ component of this vector product. It the magnitude (absolute value) of the $z$ component is small compared to magnitude of the cross product, it means that the normal is almost in the horizontal plane, so the plane is vertical. You can repeat this procedure to as many points as you want, just replace $\vec v_2$ with $\vec v_3$ and so on. However, you can easily fit a plane to a set of points, just don't use the formula where the coefficient of $z$ is one. For vertical plane you will get $|a|=|b|=|c|=\infty$. For example, look at this question.

Andrei
  • 37,370
0

The best solution in my opinion, after thinking about this for some time, is to use total least squares regression instead of ordinary least squares (OLS) regression because this allows for some measure of a best-fit plane without worrying about if the plane is vertical or not. It is of course a different definition than OLS regression, but for my needs it is equally suitable.

Argon
  • 183