0
votes

I am given N plane equations in the ax+by+cz+d=0 form, meaning we have their normals (a, b, c) and distances from the origin (d). In general, the planes are similar, so the coefficients do not differ very much. I do not have any points on the given planes, but I guess they can be sampled.

I need to find an equation of the plane which is closest to them all, i.e represents the cluster of the planes in the best way. To put it differently, I need to merge all the planes into one.

I've tried taking average of all plane coefficients, which produces a good result of the normal, but the last coefficient (d) seems wrong, the resulting plane has a small offset from the cluster.

Here is the code that averages plane equations. It uses the Eigen library:

Eigen::Vector4d merged_plane(0,0,0,0);    
// planes are normalized
for (size_t i = 0; i < planes.rows(); ++i) {
  merged_plane += planes(i);
}
merged_plane /= planes.rows();
// Normalize
merged_plane /= merged_plane.head<3>().norm();
1
Unless that equation is normalized by dividing both sides of the equation by sqrt(a*a + b*b + c*c), d is not the distance of the plane from the origin. Are the equations normalized? By "the planes are similar" do you mean that all the normalized equations, each coefficient including d is close to the same coefficient in all the other equations? By "closest" do you have a particular metric in mind or would any "close" plane suffice? Could you give us your sample data and code that averages the coefficients but gives an offset from the cluster?Rory Daulton
In order to have d represent the distance from the origin the normal vector (a,b,c) must be normalized to length 1. Maybe it suffices to normalize the average normal vector (which will have a length < 1) again to length 1.coproc
The plane equations are normalized, ||(a, b, c)||=1. By "planes are similar" I mean that all the normalized equations, each coefficient including d is close to the same coefficient in all the other equations. By "closes" I do not have a particular metric in mind.dustymax

1 Answers

0
votes

You can see the source of the problem by considering a the simpler but related problem of finding the average of two lines on the plane, say for example the lines x=1 and y=1 on the xy-plane. The average of 1x+0y and 0x+1y is 1/2 x + 1/2 y, in other words a line of slope -1.

We have the slope of the "average". Now we need to find its distance from the origin. The distance in your scheme would be the average of the distances of the two given lines, i.e., 1 and 1, so the average would be 1. The line would be tangent to the unit circle, so would pass through (1/\sqrt{2},1/\sqrt{2}) with slope -1. On the other hand, I believe you want your line to pass through the "centre of the cluster" which in this case would be the intersection of the two given lines, i.e., the point (1,1). The difference between the line of slope -1 passing through (1/\sqrt{2},1/\sqrt{2}) and the line of slope -1 passing through (1,1) is the offset that you're noticing.

Offhand I can't think of a way to fix your problem. One work-around you might try is to repeatedly pick three planes at random and find their intersection point. Then average those intersection points.

I wish I could think of a more elegant answer, but I can't right now.