
-----------------------------------
Silinter
Wed Apr 29, 2009 4:35 pm

Polygon Triangulation (Ear Cutting)
-----------------------------------
I'm trying to triangulate an arbitrary simple polygon with no holes.

The problem is that the five or six explanations out there are very vague when they come to defining an ear.
The 
fcn crossProduct (x1, y1, x2, y2 : real) : real
    result (x1 * y2) - (y1 * x2)
end crossProduct

fcn normal (x1, y1, x2, y2, x3, y3 : real) : real
    result crossProduct (x1, y1, x2, y2) + crossProduct (x2, y2, x3, y3) + crossProduct (x3, y3, x1, y1)
end normal


These are the two functions that are used to determine the normal of the polygon and the vertex in question.
The normal is calculated by going around the polygon and getting the cross product of the current vertex and it's adjacent vertex.
The normal of a vertex is calculated by entering (p(i-1).x, p(i-1).y, p(i).x, p(i).y, p(i+1).x, p(i+1).y) into the normal function. (where p is the array holding the points for the polygon and i is the vertex in question).

OP edit: solved. it was a logical problem due to poor wording. i hang on words too much T_T.
