home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math
- Path: sparky!uunet!news.smith.edu!orourke
- From: orourke@sophia.smith.edu (Joseph O'Rourke)
- Subject: Re: min distace between a point and a polygon
- Message-ID: <1992Aug18.162031.5274@sophia.smith.edu>
- Keywords: min distance
- Organization: Smith College, Northampton, MA, US
- References: <1992Aug14.142300.18732@imada.ou.dk>
- Date: Tue, 18 Aug 1992 16:20:31 GMT
- Lines: 13
-
- In article <1992Aug14.142300.18732@imada.ou.dk> hamid@imada.ou.dk (Hamid Sarabi) writes:
- >I have a point and a convex polygon(set of ordered points).
- >How can I find the distance, if the projection of the point is outside of polygon.
-
- Unless you have a very large number n of polygon vertices,
- the distance between the exterior point p and the polygon can best
- be found with the straightforward O(n) algorithm: Compute the
- distance from p to each edge e of the polygon. The distance from
- p to e is either the length of the perpendicular from p to the
- line containing e, if the foot of that perpendicular lies on e,
- or the distance from p to the closest endpoint of e.
- If your n is very large, it might be worth implementing
- a binary search on the edges to achieve O(log n) performance.
-