**comp.graphics.algorithms**

## Subject: **Distance between a Line Segment and a triangle in 3D**

Hello,

I need to calculate the distance between a line segment and a triangle.

Unfortunately Google was no good helper this time.

So i thought of something like that:

(When speaking of plane i mean the plane defined by the triangles points

and when speaking of line its the infinite line defined by the line segment)

First test if the endpoints of this given Line Segment are on opposite

sides of the plane.

If so calculate the intersection point between this plane and test if

its inside the triangle. In this case the distance would be zero.

If not: project both endpoints orthogonally onto the plane (in direction

of the planes normal) and test them if they're inside the triangle. If

one (or both) is inside, the distance would be the simple distance

between point and plane (which i could get within the projection step

already).

If this is also not the case, i would calculate the distance between the

given line segment and the 3 line segments defined through the triangle

(like discussed earlier here), taking the minimum out of these.

My problems now are:

Correctness:

I'm not sure if this would cover all cases, but until now i can't think

of an example which is not covered.

But maybe one of you had something to do with this problem and may think

of an counter-example.

Efficiency:

All in all these are a number of calculations. And for my purposes i

think i would often get to the last step (In fact i need to calculate

distances between _all_ triangles of an 3D-model and line segments of a

line-strip, at least until it gets optimized later on if possible).

As this is just a step within some precomputing, speed isn't the most

important thing. But i don't want to have enough time eating dinner or

something :)

So if anyone could point me to some other more efficient approaches i

would be thankful. (As said before google didn't help me this time, but

maybe i just searched the wrong words)

Thanks in advance,

Maik

Reply

View All Messages in

**comp.graphics.algorithms**

path:

Replies:

Re: Distance between a Line Segment and a triangle in 3D

Re: Distance between a Line Segment and a triangle in 3D

Copyright © 2006 WatermarkFactory.com. All Rights Reserved.