home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 9050 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.8 KB  |  63 lines

  1. Nntp-Posting-Host: yrsa.ifi.uio.no
  2. Newsgroups: comp.os.msdos.programmer
  3. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!espenk
  4. From: espenk@ifi.uio.no (Espen Frimann Koren)
  5. Subject: Re: Algorithm for ordering vertices
  6. Message-ID: <1992Sep4.075841.25885@ifi.uio.no>
  7. Sender: espenk@ifi.uio.no (Espen Frimann Koren)
  8. Organization: Dept. of Informatics, University of Oslo, Norway
  9. Date: Fri, 4 Sep 1992 07:58:41 GMT
  10. Lines: 50
  11. Originator: espenk@yrsa.ifi.uio.no
  12.  
  13.  
  14. In article <1992Sep3.194209.10620@athena.mit.edu> you write:
  15. >     I have a polygon with known vertices, but these points are
  16. > arranged in random order.  I need an algorithm to put these points
  17. > in an order such that I can trace the perimeter of this polygon.
  18. > Note that this arbitrary polygon can be concave and weird-shaped,
  19. > but it is simple enough that there is only ONE way to connect all
  20. > these points to form a polygon.
  21. >     Any help would be greatly appreciated.  Thanks in advance.
  22. > Gilbert
  23.  
  24.  
  25. An arbitrary set of vertices does not always become a polygon. It could
  26. turn up to be a line. What you need to sort, is the EDGES of the polygon.
  27. Then you can trace the perimeter easy.
  28.  
  29. You represent the egdes on the form (xmin, ymin, xmax, ymax) and if you
  30. sort after these criterias:
  31.  
  32.     ymin, xmin, m  (where m is the elevation of the edge, that is
  33.                         m = (ymax-ymin)/(xmax-xmin))
  34.  
  35. then a polygon like this (the P's are the crosspoints)
  36.  
  37.  
  38.  
  39.  
  40.                 Pp
  41.                p  pp  (4)
  42.                p    pp
  43.          (3)  p       pP
  44.              p         p
  45.             p          p
  46.             p          p
  47.            Ppp        p  (2)
  48.               ppp     p
  49.              (1) ppp  p
  50.                     ppP
  51.  
  52. be sorted after the shown numbering.
  53.  
  54. (This is in fact the way you sort edges if you are going to graphicly fill the
  55.  polygon using scan-conversion)
  56.  
  57. Espen.
  58.  
  59.  
  60.