1
votes

I have a point-cloud of 3d points in MATLab. The point-cloud is in the form of a 3xN matrix.

I want to calculate the normals for each of these points in the form of a 3xN matrix. How would I go about doing that?

So far I have tried using

nX = (surfnorm(X'))';

Where X is my point-cloud, and nX should be my returned normals. However, whenever I try to do it this way it doesn't seem to work when I render it... Is this the correct way to go about it?

Thanks in advance!

1

1 Answers

1
votes

surfnorm expects a surface, so it takes your 3 x N matrix of point locations as a 3 x N size surface (when calling surfnorm, input gives the Z, X and Y are set to defaults). I don't see any way of using this function directly on a point cloud.

In order to find the normals from a point cloud, you need to either:

1) Fit some sort of surface from your point cloud, and then use surfnorm on it. 2) Estimate the normal for each point, using the surrounding points. This site gives a good overview.

There is actually a file on the file exchange which demonstrates the calculation of the normal from a given set of points (a single normal from a given set of points). What you would need to do is calculate a set of nearest neighbours for each point, then return the normal vector. You may also have to correct the orientation of the vector.