Discussion:
3D cylinder to cylinder distance
(too old to reply)
Van Brackin
2005-08-10 19:17:52 UTC
Permalink
Does anyone have a way to calculate the distance between two
cylinders given the centers of each cylinder end (x,y,z) and the
diameters?

Thanks and regards,
Van
John D'Errico
2005-08-11 11:41:38 UTC
Permalink
Post by Van Brackin
Does 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
Bjorn Gustavsson
2005-08-11 12:29:36 UTC
Permalink
Post by John D'Errico
Post by Van Brackin
Does anyone have a way to calculate the distance between two
cylinders given the centers of each cylinder end (x,y,z) and
the
Post by John D'Errico
Post by Van Brackin
diameters?
I was hoping someone else would provide a better answer.
When all else fails, break out the sledge hammer.
I wonder...
Post by John D'Errico
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.
If we cant get away with much of the optimization?

The cylinders are aproximately line segments (Yep!) The vector of
shortest distance between 2 line segments are perpendicular to the
lines or from either of the ends. Same should be valid here (unless
the cylinders intersect). That gives you 1 2-D system of equations
instead. Also the vector should be normal to the cylinder surface.

If you end up outside the cylinder/can then the closest point is on
the edge (or possibly bottom/top surface if you want those included)

This is under the assumption that you have circular cylinders...

HTH,
Bjorn
Ben Barrowes
2005-08-11 14:05:37 UTC
Permalink
This problem should be able to be reduced to a smaller set of fewer
dimensional problems based on an explicit set of tests.

Center and align one cylinder at the origin, then picture all
configurations of the other cylinder and develop tests for certain cases
(cap centers are closest, closest point(s) are on rim(s), etc) to narrow
down the problem.

Quantities providing useful information include distances between {top
cap center, center, bottom cap center} for cylinder one and their
counterparts on cylinder 2. Relative angle of non-centered cylinder, etc.

After classifying a given configuration to a specific case, solving that
case should be much simpler, and in some cases a simple analytic answer
(such as the distance between a circle (rim) and a cylinder centered at
the origin). Additional end-cases include: shortest distance between two
circles in 3-space, shortest distance between two lines, shortest
distance between two planes, etc.

While offering few specifics, this approach outlined here could save
computer time at the cost of some analysis.
Post by Bjorn Gustavsson
Post by John D'Errico
Post by Van Brackin
Does anyone have a way to calculate the distance between two
cylinders given the centers of each cylinder end (x,y,z) and
the
Post by John D'Errico
Post by Van Brackin
diameters?
I was hoping someone else would provide a better answer.
When all else fails, break out the sledge hammer.
I wonder...
Post by John D'Errico
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.
If we cant get away with much of the optimization?
The cylinders are aproximately line segments (Yep!) The vector of
shortest distance between 2 line segments are perpendicular to the
lines or from either of the ends. Same should be valid here (unless
the cylinders intersect). That gives you 1 2-D system of equations
instead. Also the vector should be normal to the cylinder surface.
If you end up outside the cylinder/can then the closest point is on
the edge (or possibly bottom/top surface if you want those included)
This is under the assumption that you have circular cylinders...
HTH,
Bjorn
Continue reading on narkive:
Loading...