isValidDiagonal function
Implementation
bool isValidDiagonal(Node a, Node b) {
final b1 = a.next?.i != b.i;
final b2 = a.prev?.i != b.i;
final b3 = !intersectsPolygon(a, b);
final b41 = locallyInside(a, b);
final b42 = locallyInside(b, a);
final b43 = middleInside(a, b);
// does not create opposite-facing sectors
final b44 = area(a.prev, a, b.prev) != 0;
final b45 = area(a, b.prev, b) != 0;
final b46 = equals(a, b);
final b47 = area(a.prev, a, a.next) > 0;
final b48 = area(b.prev, b, b.next) > 0;
// locally visible
final b4 = (b41 && b42 && b43 && (b44 || b45) || b46 && b47 && b48);
// dones't intersect other edges
return b1 && b2 && b3 && b4; // special zero-length case
}