I have a bunch of points that lay on a surface on a cylinder/tube. How can I calculate the properties of this tube (radius and direction)?

The only way I can come up with is to assume find the direction vector using a least square fit, but I cant come up with the correct minimizing function. Maybe there is a better way than least square fit?

It is ok to assume that the points are evently spaced/spread out around the tube.


2 Answers 2


Did you consider looking at the PCA of the point cloud? The eigen directions will show you where the long direction of the cylinder is pointing, and then you can project all the points to a plane that is orthogonal to the long axis and fit to a circle.

  • $\begingroup$ I did not think of that. I feel like it should work, thank you! $\endgroup$
    – lijas
    Dec 5, 2018 at 8:29
  • $\begingroup$ Do you know if PCA would find the cylinder's axis when the point cloud only covers a patch of the surface, even a strange shaped patch, like a segment of a helix? Of course, there would be enough points to uniquely determine the cylinder's orientation too. $\endgroup$ Oct 4, 2020 at 1:34
  • $\begingroup$ Probably not. I think you would need a non linear optimization, based on finding the plane where the projected points are on a sharp circle. $\endgroup$
    – user619894
    Oct 4, 2020 at 7:00

I came up with a better solution than a pca I think.

I have defined an objective function that tries to minimize the variance of the points distances from the line, and solve it using scipy least squares.

You try to find 6 parameters that define a line in a 3d space, calculate the distances of the points from that line, calculate their variance and try to minimize this value


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .