Fit a cylinder to scattered 3D XYZ point data
As in the title, I want to fit a cylinder to a group of 3D points with Python. This is a nice solution with MATLAB . How can we do it with Python? There is paper at David Eberly site "Fitting 3D Data with a Cylinder" that describes math basics and shows pseudocode. You can also refer to C++ code in Geometric Tools Engine at the same site. I think that some auxiliary math functions like matrix inverse etc could be implemented in NymPy. Using scipy.optimize.leastsq, we can create an error function in which the difference between the observed cylinder radius and the modelled radius is minimized.