Can we specify an "outward" direction to normal obtained from pcfitplane approach?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
William Rose
2024-9-2
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 个评论
更多回答(1 个)
Matt J
2024-9-2
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!