Can we specify an "outward" direction to normal obtained from pcfitplane approach?

4 views (last 30 days)
I would like to fit a plane to a set of 3d points, but I have a general idea of direction towards which the plane normal should point to. For eg., if the planes represent the faces of a cuboid, it should point away from the centre or if I am fitting the surface of the ground, then it should point upwards, etc.
I can see that pcfitplane has a reference vector option, but that's too restrictive. Is there some other way where I can somehow provide such constraints to the normal vector? As of now, since it's ransac in the background, the final normal vector randomly points in either direction, whereas I would like a consistent output.

Accepted Answer

William Rose
William Rose on 2 Sep 2024
I agree with @Matt J. To be more specific:
Assume n is the normal vector returned by pcfitplane.
If you want n to point generally up from the ground, then you must know z, the vector that points vertically up. So you do
if dot(n,z)<0
n=-n;
end
If you want n to point away from the center of a cube, then you must know cc, a vector for the approximate center of the cube, and vector cp, which is the centroid of the ponts that were used to fit the plane. (The centroid of the points used to fit the plane will always be in the fitted plane.) Then do
if dot(n,cp-cc)<0
n=-n;
end
Good luck.

More Answers (1)

Matt J
Matt J on 2 Sep 2024
I doubt you can, but it shouldn't matter. If the normal is pointing the wrong way, just post-process the fit by flipping its direction. A constraint on the direction shouldn't affect the quality of the fit, if that's what you were worried about.
  1 Comment
Manish Kumar Nayak
Manish Kumar Nayak on 2 Sep 2024
Not really worried about the quality of the fit. However, I had multiple point clouds and wanted to do some automation and achieve consistent results. Suggestion by @William Rose should be an apt way to fix this. Thanks for the input.

Sign in to comment.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!