//check if a given polygon2d has any of its longer edges aligned with any edge of the containerpolygon2d internal static bool CheckPolyGetsExternalWall(Polygon2d poly, Polygon2d containerPoly, double shortEdgeDist = 16, bool tag = true) { bool check = false; if (!ValidateObject.CheckPoly(poly)) { return(check); } Polygon2d polyReg = new Polygon2d(null); //make given polys reduce number of points if (tag) { polyReg = new Polygon2d(poly.Points); } else { polyReg = poly; } Polygon2d containerPolyReg = new Polygon2d(containerPoly.Points); for (int i = 0; i < polyReg.Points.Count; i++) { int a = i, b = i + 1; double eps = 0; if (i == polyReg.Points.Count - 1) { b = 0; } double distance = PointUtility.DistanceBetweenPoints(polyReg.Points[a], polyReg.Points[b]); List <double> spansSorted = PolygonUtility.GetPolySpan(containerPolyReg); if (distance <= spansSorted[0] * 0.75) { continue; } Line2d lineA = Line2d.ByStartPointEndPoint(polyReg.Points[a], polyReg.Points[b]); for (int j = 0; j < containerPolyReg.Points.Count; j++) { int c = j, d = j + 1; if (j == containerPolyReg.Points.Count - 1) { d = 0; } Line2d lineB = Line2d.ByStartPointEndPoint(containerPolyReg.Points[c], containerPolyReg.Points[d]); check = GraphicsUtility.LineAdjacencyCheck(lineA, lineB, eps); if (check) { break; } } if (check) { break; } } return(check); }