Can we specify an "outward" direction to normal obtained from pcfitplane approach?
4 views (last 30 days)
Show older comments
Manish Kumar Nayak
on 2 Sep 2024
Commented: William Rose
on 3 Sep 2024
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.
0 Comments
Accepted Answer
William Rose
on 2 Sep 2024
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.
2 Comments
More Answers (1)
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.
See Also
Categories
Find more on Point Cloud Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!