Hey,

I have a set of points which should lie on a cylinder but are not fairly distributed on it. I need to get the optimal parameter values that can describe such a cylinder.

Does anybody have an idea or a pointer to solve this problem?

Thanks!

Hey,

I have a set of points which should lie on a cylinder but are not fairly distributed on it. I need to get the optimal parameter values that can describe such a cylinder.

Does anybody have an idea or a pointer to solve this problem?

Thanks!

“not fairly distributed on it”

I assume it means that all points are not placed randomlny ON cylinder’s surface but NEAR cylinder’s surface.

If they’re just near the cylinder then you can try simple genetic algorithm. One such algorith could look like that:

You need to find two points - center of cylinder’s top and center of cylinder’s bottom.

You do that by creating two random points and calculating how good is your current solution.

If it’s not good enough then modify one or more coordinates and see if it got any better. Keep doing that until you are satisfied. As your solution gets better, modify your point’s coordinates by lesser and lesser values.

Very easy so far, but now the hard part - we need a function that will tell us how good is our current solution.

- Let’s call our points A and B
- Create vector V1 = normalize(B - A)
- Create plane PA = (V1.x, V1.y, V1.z, dot(V1, A))
- Create plane PB = (V1.x, V1.y, V1.z, dot(V1, B))
- Now for every point X = (x, y, z, 1) calculate DA = dot(X, PA) and DB = dot(X, PB)
- Create some threshold T - let’s say it’s 5-10% if distance between A and B
- Every point with DA <= T is “Bottom” point
- Every point with DB >= -T is “Top” point
- All other points are “Middle” points
- For all “Top” points compute sum of abs(DB)
- For all “Bottom” points compute sum of abs(DA)
- For all middle points compute distance from cylinder’s axis: R = length(cross(X.xyz - A.xyz, V.xyz)) - remember minimum (Rmin) and maximum (Rmax) distances
- If sum of all distances (abs(DA) and (abs(DB))and difference between Rmin and Rmax is less than your current “best” solution’s then you have found better solution.

Of course you should search for solution as long as it keeps improving.

Using cylindrical coords :

theta = RAND

x = RAND

et voila

EDIT: Ok, I misunderstood the inputs and the outputs wanted …

mmm… Well… i think the genetic algorithm sounds like a good idea… since I need to optimize the cylinder radius and center axis… I just hoped there could be a more straight forward regression-type method…

Many Thanks!