The algorithm is as following:

realize you have polygon with ABCDEF as vertices

1. make sure you have all the points to the right (clockwise)
2. you have to write (or use) atan2 (for comparing angles)
3. start with A, and compute angle between ABC (AB-BC).
4. if it's convex, you've triagle, so push ABC into triangle array and
   remove vertex B
5. if it's concave, move to next vertex (eg. BCD), and repeat steps until you
   have no vertices to test :)

then you have n-2 triangles to fill. n is the number of polygon vertices

note: you always have to remove/test angles from the middle vertex you test!
      convex angle is < 180 degrees

btw - look here:
http://orin.meinlschmidt.org/~znouza/projects/palm/bludicka/a/fill2.php?

and try to write the number of triangles you have to see filled. maximum
number of triangles in given polygon is written in image (14), so try number
from 1 to 14. You might see how is concave polygons handled. it's simple, fast,
and easy to manage.

feel free to ask me

/tom

On Fri, Aug 27, 2004 at 02:32:51PM -0000 Luc Le Blanc [EMAIL PROTECTED] wrote:
> Tomas Meinlschmidt wrote:
> 
> > You have to decide the orientation (left/right), define Top,
> > middle and bottom
> > point of triangle and compute deltas between top-bottom,
> > top-middle,
> > bottom-middle. So you know about the height (y1-y2) of triangle,
> > and that;s all you need to know
> 
> > I wrote the following:
> 
> [snip]
> 
> Thanks for the algorithm. By any chance, can you point me to a relevant ressalate 
> implementation? So far, the research I made on the subject led me to ideas about 
> multiplying polygons, not splitting them into triangles. Do you know of any grafic 
> library for the Palm that would already implement these algorithms?
> 
> 
> -- 
> Luc Le Blanc
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe, please see 
> http://www.palmos.com/dev/support/forums/

-- 
===============================================================================
Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache
gPG fp: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56
GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) !o
    !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G e>+++
    h---- r+++ z+++@
===============================================================================

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to