I am programming in C++ with the PCL, point cloud, library.
My problem is: computing the variance of some of the points but only with respect to the perpendicular axis w
you need basis vectors for this ... so let N
be your plane normal. To interpolate your plane you need 2 basis vectors U,V
inside your plane and one start point P0
belonging to that plane...
Lets assume we know N,P0
so the U,V
can be computed by exploiting cross product:
// U is any vector non parallel to N
U = (1.0,0.0,0.0)
if (|dot(U,N)|>0.75) U = (0.0,1.0,0.0)
// make U,V perpendicular to N and each other
V = cross(N,U)
U = cross(V,N)
// normalize U,V,N
U = U/|U|
V = V/|V|
N = N/|N|
Now any point on plane can be interpolated like this:
P(u,v) = P0 + u*U + v*V
Where u,v
are your interpolation scalar parameters which are also equal to perpendicular distance of P(u,v)
in U
and V
directions from P0
.
To evaluate the distance of your point from the plane (altitude) you can simply do this
alt = dot(N,P(u,v)-P0)
so no quadratics is needed ... Similarly if you need the u,v
for some point P
you can do this:
u = dot(U,P-P0)
v = dot(V,P-P0)