We need to fit a set of points (x,y,z) to plane and get fitted value of Z - Zi at a point (Xi,Yi).
We have used Eigen Library for plane fitting. https://gist.github.com/ialhashim/0a2554076a6cf32831ca
Now we have the normal to the plane and centroid of all points.
How can I can calculate the value of Z axis at a point (xi, yi) with the following information?
- Centroid of all points
- Normal to the fitted plane
The equation of the plane with normal vector $\hat n$ passing though the point $p$ is $$\hat n \cdot v = \hat n \cdot p$$. This is a linear equation of the form $$ax + by + cz = d$$where $\hat n =(a, b, c), d = \hat n \cdot p$, and $v = (x,y,z)$. as long as $c \ne 0$, $$z = \frac dc - \frac acx -\frac bcy$$
If $c = 0$, then for all values of $z$, the point $(x_i, y_i, z)$ will be on the plane.