[comp.graphics] triangles from polygons

naughton@sun.soe.clarkson.edu (Patrick Naughton) (04/14/88)

Problem:
  Given a polygon defined in three-space with three or more co-planar
vertices create a list of triangles which don't overlap and yet cover
the entire surface of the original n-agon. 

  Fact:  The number of triangles, t generated by an n-agon is [n-2;n>=3].

This may seem trivial...

My first attempt was this:

Given a polygon with vertices v[0]...v[n-1]:

 j = [2..n-1]
   a triangle is <v[0],v[j-1],v[j]>
 
This will work iff the vertices are numbered in order reading clockwise
or counterclockwise around the polygon. 

For example:

      Correct            Incorrect

     v0----v1            v0----v1
      |\    |             |\  /
      | \   |             | \/
      |  \  |             | /\
      |   \ |             |/  \
     v3----v2            v2----v3

This problem obviously compounds when the number of vertices increases.

I know that this has been done... SunCore handles it internally...

If anyone can suggest a reference to this and other related problems
such as how to resolve which polygon should be drawn first in a Z-buffer
sort when the vertices overlap in the Z dimension...  I'd be highly
thankful...


For the curious, I'm doing Gouraud/Phong shading under X11 and I've written
the shading routines to deal with triangles and I now see that most 3d
poly data is in n-agon format... sigh...

-Patrick	 ___________________________________________
		|                                           |
		|  Internet: naughton@sun.soe.clarkson.edu  |
		|  BITNET:   naughton@CLUTX.BITNET          |
		|  uucp:     {rpics, gould}!clutx!naughton  |
		|___________________________________________|

		    Soon to be naughton@sun.com (6/1/88)