🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1277

Re: Algorithm for ordering vertices

#1277
From: Espen Frimann Koren
Date: Fri, 04 Sep 1992 07:58
48 lines
1934 bytes
In article <1992Sep3.194209.10620@athena.mit.edu> you write:
> 	I have a polygon with known vertices, but these points are
> arranged in random order.  I need an algorithm to put these points
> in an order such that I can trace the perimeter of this polygon.
> Note that this arbitrary polygon can be concave and weird-shaped,
> but it is simple enough that there is only ONE way to connect all
> these points to form a polygon.
> 
> 	Any help would be greatly appreciated.  Thanks in advance.
> 
> Gilbert
> 


An arbitrary set of vertices does not always become a polygon. It could
turn up to be a line. What you need to sort, is the EDGES of the polygon.
Then you can trace the perimeter easy.

You represent the egdes on the form (xmin, ymin, xmax, ymax) and if you
sort after these criterias:

	ymin, xmin, m  (where m is the elevation of the edge, that is
                        m = (ymax-ymin)/(xmax-xmin))

then a polygon like this (the P's are the crosspoints)




                Pp
               p  pp  (4)
               p    pp
         (3)  p       pP
             p         p
            p          p
            p          p
           Ppp        p  (2)
              ppp     p
             (1) ppp  p
                    ppP

be sorted after the shown numbering.

(This is in fact the way you sort edges if you are going to graphicly fill the
 polygon using scan-conversion)

Espen.
Technical Details
Message-ID: <1992Sep4.075841.25885@ifi.uio.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!espenk

Show Full Headers
Complete Article Headers
Nntp-Posting-Host: yrsa.ifi.uio.no
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!espenk
From: espenk@ifi.uio.no (Espen Frimann Koren)
Subject: Re: Algorithm for ordering vertices
Message-ID: <1992Sep4.075841.25885@ifi.uio.no>
Sender: espenk@ifi.uio.no (Espen Frimann Koren)
Organization: Dept. of Informatics, University of Oslo, Norway
Date: Fri, 4 Sep 1992 07:58:41 GMT
Lines: 50
Originator: espenk@yrsa.ifi.uio.no