public static Rct Bounds(IEnumerable <Pt> pc, Mat xform) { Rct bounds = Rct.Null; foreach (Pt p in pc) { bounds = bounds.Union(xform * p); } return(bounds); }
static bool doubleLoop(Stroq s) { int closeInd = 0; double nearest = double.MaxValue; Pt first = s[0]; for (int i = s.Count / 4; i < 3 * s.Count / 4; i++) { if ((s[i] - first).Length < nearest) { nearest = (s[i] - first).Length; closeInd = i; } } if (nearest < s.GetBounds().MaxDim *.4 && closeInd > 2 && closeInd < s.Count - 2) { List <Pt> clipped = new List <Pt>(s.Select <Pt, Pt>((Pt p) => p)); List <Pt> clipped2 = new List <Pt>(s.Select <Pt, Pt>((Pt p) => p)); clipped.RemoveRange(closeInd, s.Count - closeInd); clipped2.RemoveRange(0, closeInd); Rct r1 = Rct.Null; Rct r2 = Rct.Null; foreach (Pt p in clipped) { r1 = r1.Union(p); } foreach (Pt p in clipped2) { r2 = r2.Union(p); } Rct r3 = r1.Union(r2); Rct inter = r1.Intersection(r2); if (isCircular(clipped.ToArray()) && isCircular(clipped2.ToArray()) && inter.Width / (float)r1.Width > 0.5 && inter.Height / (float)r1.Height > 0.5 && inter.Width / (float)r2.Width > 0.5 && inter.Height / (float)r2.Height > 0.5 && inter.Width / (float)r3.Width > 0.5 && inter.Height / (float)r3.Height > 0.5) { return(true); } } return(false); }