Discussion:
Distance Cylinder to Triangle in 3D
(too old to reply)
k***@gmail.com
2013-11-30 14:44:59 UTC
Permalink
Hello,
I try to calculate the distance between a 3D cylinder to a 3D planar triangle. I found some implementations regarding line segment to triangle (http://www.geometrictools.com/LibMathematics/Distance/Distance.html) and distance between cylinder and point (http://liris.cnrs.fr/Documents/Liris-1297.pdf) - However, I have problems to find a good solution to calculate the distance between a cylinder and a triangle. My first idea was to calculate the distance segment to triangle and to substract the radius of the cylinder. But this would create spherical ends rather than discs on the cylinder. I found also algorithms to calculate the intersection of cylinder and triangle (http://www.geometrictools.com/LibMathematics/Intersection/Intersection.html). But to extend this to distance rather than intersection doesn't seem to be straight forward.

I wonder whether there is acutally a solution to my problem or if this problem cannot be solved without approximation.

I would be thankfull for any help,

Konrad
Hans-Bernhard Bröker
2013-12-01 17:15:52 UTC
Permalink
Post by k***@gmail.com
I try to calculate the distance between a 3D cylinder to a 3D planar
triangle.
This begs the question what you mean by cylinder. Half of computer
graphics assumes that term to mean an infinite cylinder, the other half
a finite one (with flat endings).

What this basically boils down to is to compute one-on-one distances
between all pairs of edges, vertices and surfaces available, and find
the smallest one.
Konrad Leibrandt
2013-12-01 20:24:00 UTC
Permalink
Post by Hans-Bernhard Bröker
This begs the question what you mean by cylinder. Half of computer
graphics assumes that term to mean an infinite cylinder, the other half
a finite one (with flat endings).
I meant a non-infinite cylinder which is described by two vertices a,b (describing the centre line of the cylinder, where u=(b-a)/||b-a|| is the unit axis vector) and a radius r. Thus the cylinder I mean has two end-discs.

I would assume you are right, but I don't find it that straight forward to calculate the distance between a triangle and a cylinder disc or cylinder side.

I think I know how to calculate the distances between the disc and the triangle. Although I haven't quite figured it out yet. Anyways, regarding the side/lateral surface of the cylinder I'm even less sure.

Because as I said before when I consider the cylinder just as a line and substract the radius from the centreline-triangle distance I would get spherical ends rather than discs. And I couldn't just take the shortest distance.
Hans-Bernhard Bröker
2013-12-02 00:37:31 UTC
Permalink
Post by Konrad Leibrandt
I think I know how to calculate the distances between the disc and
the triangle. Although I haven't quite figured it out yet. Anyways,
regarding the side/lateral surface of the cylinder I'm even less
sure.
The key to most such calculations is that the line of shortest distance
has to be orthogonal to both things it connects. Among other things,
this means that some combinations can be discarded. I.e. the shortest
line cannot really be between points in the interior of an end disc and
the interior of the triangle. If the closest pair contains a point in
the interior of the cylindrical surface, the problem can be projected to
a 2D circle<-->triangle one.

And beware of ugly special cases like the triangle enclosing the
cylinder axis...
Konrad Leibrandt
2013-12-03 00:33:06 UTC
Permalink
Post by Hans-Bernhard Bröker
The key to most such calculations is that the line of shortest distance
has to be orthogonal to both things it connects. Among other things,
this means that some combinations can be discarded. I.e. the shortest
line cannot really be between points in the interior of an end disc and
the interior of the triangle. If the closest pair contains a point in
the interior of the cylindrical surface, the problem can be projected to
a 2D circle<-->triangle one.
And beware of ugly special cases like the triangle enclosing the
cylinder axis...
Thank you a lot Hans, I'm aware of the standard situations of 0,1-dimensional structures and the perpendicular connection lines. But having two planes (disc, triangle) is so far a bit more challenging, since there are more things to take into account. I think I will calculate the distance between the three edges of the triangle to the disc and than I'm left with calculating the shortest distance of the infinite-plane which has the same normal as the triangle to the disc. And, you are right that this distance has to lie on the edge of the disc. I wasn't aware of this.

These ugly cases shouldn't be actually relevant to my case since in my application cylinder and triangle are not meant to intersect.But even if they are I think I should have covered this. Thanks a lot.
Loading...