Fitting cylinder to data points

Hi All,

I am not sure if this is the correct place for this question, so please pardonme if it's not.

I have a small task to perform and have no to very little clue where to start.

I have been given a set of data points (± 500), that roughly represent theoutside of a cylinder (the cylinder is arbitrarily orientated in 3D space). Iam looking for a way to do two things:

a.) Find the cylinder that best fits this data

b.) Measure the distance from each individual point to the surface of thatcylinder, or the distance from each point to the axis of the cylinder.

I want to code this in C++ by reading the data points, but am stuck the whereto find the correct algorithm, or perhaps make sense of the algorithms I havealready found.

If anyone has some advice on where to start that would be very muchappreciated.

Regards

Rob