Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!yoyodyne!marcc From: marcc@yoyodyne.ncsa.uiuc.edu (Marc Cooper) Newsgroups: comp.graphics Subject: Re: Distance from Point to a Polygon? (Algorithm wanted) Keywords: polygon point distance Message-ID: <1991Jan4.191630.12650@ux1.cso.uiuc.edu> Date: 4 Jan 91 19:16:30 GMT References: <1991Jan4.131532.3933@jarvis.csri.toronto.edu> Sender: news@ux1.cso.uiuc.edu (News) Organization: National Center for Supercomputing Applications at Urbana Illinois Lines: 29 In article <1991Jan4.131532.3933@jarvis.csri.toronto.edu> corkum@csri.toronto.edu (Brent Thomas Corkum) writes: > > >I'm looking for a FAST algorithm for calculating the distance from a >point in 3 space to a polygon (not the plane of the polygon) in 3 space. >It only need work for convex three noded triangles and four noded >quadralaterals. >corkum@boulder.civ.toronto.edu This seems easy enough, given the simplied case. First, calculate the distance from the point to the polygonal plane. If the intersection point is within the polygon, stop. That is the shortest distance. If the perpendicular dropped from the point to the polygonal plane lies OUTSIDE the polygon, calculate the distance from each vertex of the polygon to the point. Then find the minimum distance between the point and the line segment defined by the two closest vertecies. I don't know how fast this would be. I suppose that depends if you're willing to hack out the calculations in the relevent assembley language or not.. -- Marc Cooper | "In my childhood, I WAS an imaginary playmate." marcc@ncsa.uiuc.edu | -Tom Robbins, EVEN GOWGIRLS GET THE BLUES National Center for Supercomputing Applications Disclaimer: "It's mine! All mine!" -D. Duck