C++ plane interpolation from a set of points

前端 未结 1 1260
我寻月下人不归
我寻月下人不归 2021-01-29 07:45

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

相关标签:
1条回答
  • 2021-01-29 08:00

    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)
    
    0 讨论(0)
提交回复
热议问题