bool isSimple()

Source

bool isSimple() {

  int length = points.length;
  if (length <= 3) return true;

  for(int i = 0; i < length; i++) {

    Point<num> a1 = points[i];
    Point<num> a2 = points[i + 1 < length ? i + 1 : 0];

    for(int j = 0; j < length; j++) {

      if ((i - j).abs() < 2) continue;
      if (j == length - 1 && i == 0) continue;
      if (i == length - 1 && j == 0) continue;

      Point<num> b1 = points[j];
      Point<num> b2 = points[j + 1 < length ? j + 1 : 0];

      if(_getLineIntersection(a1, a2, b1, b2) != null) return false;
    }
  }

  return true;
}