Calculate Z Values from a plane normal

270 Views Asked by At

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?

  1. Centroid of all points
  2. Normal to the fitted plane

Thanks!

1

There are 1 best solutions below

2
On BEST ANSWER

You want the distance d to the plane of a point r=(xi,yi,zi).

You have the plane normal n=(nx,ny,nz) that should be a unit vector, and a single point on the plane p=(px,py,pz).

d = nx*(xi-px) + ny*(yi-py) + nz*(zi-pz)

which is the dot product between the normal n and the relative position r-p.

Or, if you want the equation of the surface of the plane, then solve the equation below for zi

nx*(xi-px) + ny*(yi-py) + nz*(zi-pz) = 0

zi = pz - (nx*(xi-px)+ny*(yi-py))/nz