# Fitting a plane through a 3D point data

89 views (last 30 days)
ha ha on 6 May 2018
Edited: Matt J on 6 May 2018
For example, i have 3d point cloud data [xi, yi, zi] as the attachment .txt file. I want to fit a plane to a set of 3D point data. What kind of method to do that?
Matt J on 6 May 2018
How does one know that M and L are different planes and not just noise? Is there a known upper bound on the noise? A known lower bound on the separation distance between M and L?

Matt J on 6 May 2018
You will probably have to implement a RANSAC plane fitting routine.
Matt J on 6 May 2018
One approach you might consider is to take planar cross sections of your data. This will give 2D data for a line, with outliers. Then you can apply a ready-made RANSAC line-fitter, like the one I linked you to. From line fits in two or more cross-secting planes you should be able to construct the desired plane K.

Walter Roberson on 6 May 2018
coeffs = [data(:,1:2), ones(size(data,1),1)]\data(:,3);
The equation of the plane is then coeffs(1)*x + coeffs(2)*y - coeffs(3) = z
ha ha on 6 May 2018
From your answer, I plot the surface as below image. But That plane is not same as my expected plane. If we use the formulas as your proposed method, the plane is fitting through all points & will be slightly different with my expected plane K(=plane M)

Matt J on 6 May 2018
Edited: Matt J on 6 May 2018
xyz(xyz(:,2)>40, :)=[];
mu=mean(xyz,1);
[~,~,V]=svd(xyz-mu,0);
normal=V(:,end).';
d=normal*mu';
The equation of the plane is then xyz*normal.' = d
Matt J on 6 May 2018
How does one know that M and L are different planes and not just noise? Is there a known upper bound on the noise? A known lower bound on the separation distance between M and L?

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!