public static int Triangulize(Polygon p, out List<Triangle> triangulated) { triangulated = null; if (p.nVertices < 3) return 0; triangulated = new List<Triangle>(); int nTri; if (p.IsCCW()) { //printf("It is ccw \n"); Polygon tempP = new Polygon(); tempP.Set(p); ReversePolygon(tempP.x, tempP.y); nTri = TriangulatePolygon(tempP.x, tempP.y, triangulated); // ReversePolygon(p->x, p->y, p->nVertices); //reset orientation } else { //printf("It is not ccw \n"); nTri = TriangulatePolygon(p.x, p.y, triangulated); } if (nTri < 1) { //Still no luck? Oh well... return -1; } return nTri; }