public static double MaxDist(Point[] pts, Point baseP, PointF dir, out bool left, out int index, int start, int end) { double farthest = 0, farleft = 0, farright = 0; left = false; index = start; for (int i = start + 1; i < end - 1; i++) { PointF near = V2D.Add(baseP, V2D.Mul(dir, V2D.Dot(V2D.Sub(pts[i], baseP), dir))); PointF offset = V2D.Sub(pts[i], near); double dist = V2D.Length(offset); if (dist > farleft && offset.X < 0) { farleft = dist; } if (dist > farright && offset.X > 0) { farright = dist; } if (dist > farthest) { farthest = dist; index = i; left = offset.X < 0; } } return(Math.Max(farthest, farleft + farright)); }
public void ScaleToRectangle(Rectangle oldR, Rectangle r) { for (int i = 0; i < baselinealts.Length; i++) { baselinealts[i] = (int)((baselinealts[i] - oldR.Top + 0.0) / oldR.Height * r.Height + r.Top); } for (int i = 0; i < xheightalts.Length; i++) { xheightalts[i] = (int)((xheightalts[i] - oldR.Top + 0.0) / oldR.Height * r.Height + r.Top); } _bbox.Offset(V2D.Sub(r.Location, oldR.Location)); }
public static double Straightness(Point[] pts, int start, int end, double dist, out bool left) { return(Straightness(pts, V2D.Sub(pts[Math.Min(pts.Length - 1, end)], pts[start]), start, end, dist, out left)); }
public static double Straightness(Point[] pts, Point dir, int start, int end, double dist, out bool left) { return(MaxDist(pts, V2D.Normalize(dir), out left, start, end) / dist); }
public static double Det(Point a, Point apex, Point b) { return(Det(V2D.Sub(a, apex), V2D.Sub(b, apex))); }