[comp.graphics] Distance from a point to a polygon in 3-space

corkum@csri.toronto.edu (Brent Thomas Corkum) (04/12/91)

I'm looking for a reference, algorithm or C code snipit that calculates
the EXACT distance from a 3D point to 3D CONVEX polygon (always a triangle or
quadralateral).  In the end though, I need to calculate the distance from
a point to a closed CONCAVE or CONVEX object made up of these polygons.
The way I would do it now is to test 2 cases for each polygon, 1) calculate the
normal distance to the polygon plane and the intersection point on the plane.
If the intersection point is within the bounds of the polygon use this
distance, else go to step 2. 2) Calculate the distance to each of the
edge lines of the polygon. Since my object is closed and my test points
are all outside my object I would also filter out backfacing polygons first.
(I think this would work anyways!)

This must be a common problem in computer graphics with lots of efficient
algorithms for solution although I've looked in a variety of texts with little
success.

Brent Corkum
corkum@boulder.civ.toronto.edu

sow@cad.luth.se (Sven-Ove Westberg) (04/13/91)

In article <1991Apr12.000218.3215@jarvis.csri.toronto.edu> corkum@csri.toronto.edu (Brent Thomas Corkum) writes:
|I'm looking for a reference, algorithm or C code snipit that calculates
|the EXACT distance from a 3D point to 3D CONVEX polygon (always a triangle or
|quadralateral).  In the end though, I need to calculate the distance from

You can not calulate the EXACT distance to a quadralateral if it is not
planar. On non planar quadralateral the distance depends on how you
define the surface. One common way do do it is to divide each quadralateral
in two triangels. You can divide the quadralateral in two ways and
get different results.

Sven-Ove Westberg, CAD, University of Lulea, S-951 87 Lulea, Sweden.
Internet: sow@cad.luth.se