POV-Ray : Newsgroups : povray.binaries.images : Polygon Triangulation : Re: Polygon Triangulation Server Time
6 Aug 2024 21:33:14 EDT (-0400)
  Re: Polygon Triangulation  
From: Tim Attwood
Date: 25 Aug 2006 04:26:11
Message: <44eeb423$1@news.povray.org>
> Looks good! What technique for triangulation do you use? I've been 
> experimenting with triangulation, too.

The polygon is evaluated from a spline, after checking that the shape
is closed, it checks if the shape is defined clockwise or
counter-clockwise by finding the left-most point (at least one) and
figuring the angles. If it's counter-clockwise it reverses the array of 
points.

Method 1, for the polygon on the right, doesn't create any inside
points, but finds the inside angle nearest to 60 degrees, then tests
for a point inside the triangle, and removes the ear. Rinse-repeat.

Method 2, for the polygon on the left does the same thing, but if
the ratio of the longest side to the shortest side of the ear was below
a number (4 in the image) then it created two triangles, split at the
midpoint, and moved the "current" point (in a "last--current--next" 
triangle)
to the midpoint of "last--next".

>You can find my results at
> http://www.wikipov.org/ow.asp?PolyFunctions

Cool, I'll have to look thru polyfunctions!

> Do you have any specific purpose in mind for your triangulation code?

I was just going to close an end cap on an extruded spline mesh, but
became interested in the math involved while reading Wikipedia.

At first I had a macro similar to Side_Of_Line, but abandoned it in favor
of the inside angle, if the angle is greater or equal to 180 it's convex...

Sometimes VAngleD is warning about acos ranges, and sometimes the
return from the sort was degenerates.

I used Heron's formula for the area of a triangle to test for degenerates,
it might be finding very small triangles too, which is fine by me, since
it seems bad to have triangles too small. Normalizing the vectors is
a neat trick though.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.