Fit a plane to a list of (more than three) points.
points (list of list) – A list of points represented by their XYZ coordinates.
plane (tuple) – Base point and normal vector (normalized).
This method will minimize the squares of the residuals as perpendicular to the main axis, not the residuals perpendicular to the plane. If the residuals are small (i.e. your points all lie close to the resulting plane), then this method will probably suffice. However, if your points are more spread then this method may not be the best fit. For more information see [ernerfeldt2015]
Ernerfeldt, E. Fitting a plane to many points in 3D. Available at: http://www.ilikebigbits.com/blog/2015/3/2/plane-from-points