Post by Van BrackinDoes anyone have a way to calculate the distance between two
cylinders given the centers of each cylinder end (x,y,z) and the
diameters?
I was hoping someone else would provide a better answer.
When all else fails, break out the sledge hammer.
Its an optimization problem, in 6 unknowns. Parameterize
any point on (or in) each cylinder using cylindrical
coordinates. Then minimize the distance between the
pair of points.
You need to parameterize the entire cylinder, allowing
points to move inside to move between ends of the
cylinders and onto the rounded surfaces. Otherwise the
optimization can easily get stuck in a local minimum.
Allowing a point to move inside makes the problem
well-posed in this respect.
Use fmincon from the optimization toolbox, because the
cylinders have finite length and radius. (You can get
around this, but it takes some work in the cylindrical
parameterization.)
Remember that the two cylinders will be living in their
own (distinct) cylindrical coordinate systems, you need
to deal with this to compute the distance.
Oh, if the cylinders intersect, then the distance
found will be zero, but the points chosen may be
arbitrary.
HTH,
John D'Errico
--
The best material model of a cat is another, or
preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945