public bool IsSimple() { bool flag = base.Count < 3; bool result; if (flag) { result = false; } else { for (int i = 0; i < base.Count; i++) { TSVector2 tSVector = base[i]; TSVector2 tSVector2 = this.NextVertex(i); for (int j = i + 1; j < base.Count; j++) { TSVector2 tSVector3 = base[j]; TSVector2 tSVector4 = this.NextVertex(j); TSVector2 tSVector5; bool flag2 = LineTools.LineIntersect2(ref tSVector, ref tSVector2, ref tSVector3, ref tSVector4, out tSVector5); if (flag2) { result = false; return(result); } } } result = true; } return(result); }
/// <summary> /// Checks if the vertices forms an simple polygon by checking for edge crossings. /// </summary> public bool IsSimple() { //The simplest polygon which can exist in the Euclidean plane has 3 sides. if (Count < 3) { return(false); } for (int i = 0; i < Count; ++i) { TSVector2 a1 = this[i]; TSVector2 a2 = NextVertex(i); for (int j = i + 1; j < Count; ++j) { TSVector2 b1 = this[j]; TSVector2 b2 = NextVertex(j); TSVector2 temp; if (LineTools.LineIntersect2(ref a1, ref a2, ref b1, ref b2, out temp)) { return(false); } } } return(true); }