void solver_DebugMaxMin(FractionPoint max, FractionPoint min, Fraction f_tan) { if (df == null) { df = new DekartForm(100, 100, 100, 100); df.Text = "max & min"; } // n df.AddPolygon(Color.Black, DrawModes.DrawLines, new PointF(1000, f_tan * 1000), new PointF(-1000, -f_tan * 1000)); int id1 = df.AddPolygon(Color.Orange, DrawModes.DrawLines, new PointF(1000 + max.X, -1 / f_tan * 1000 + max.Y), new PointF(-1000 + max.X, 1 / f_tan * 1000 + max.Y)); int id2 = df.AddPolygon(Color.CornflowerBlue, DrawModes.DrawLines, new PointF(1000 + min.X, -1 / f_tan * 1000 + min.Y), new PointF(-1000 + min.X, 1 / f_tan * 1000 + min.Y)); df.Update2(); df.AddPolygon(Color.Orange, 3f, DrawModes.DrawPoints, new PointF(max.X, max.Y)); df.AddPolygon(Color.CornflowerBlue, 3f, DrawModes.DrawPoints, new PointF(min.X, min.Y)); df.Show(); df.Update2(); }
protected void OnMaxMinPoints(FractionPoint max, FractionPoint min, Fraction f_tangence) { if (DebugMaxMinPts != null) { DebugMaxMinPts(max, min, f_tangence); } }
void solver_DebugMaxMin(FractionPoint max, FractionPoint min, Fraction f_tan) { if (df == null) { df = new DekartForm(100, 100, 100, 100); df.Text = "max & min"; } df.Use_IsVisible = false; // n df.AddPolygon(Color.Black, DrawModes.DrawLines, new PointF(1000, f_tan * 1000), new PointF(-1000, -f_tan * 1000)); for (float percent = 0; ; percent += .05f) { int id1 = df.AddPolygon(Color.Black, DrawModes.DrawLines, new PointF(1000 + max.X * percent, -1 / f_tan * 1000 + max.Y * percent), new PointF(-1000 + max.X * percent, 1 / f_tan * 1000 + max.Y * percent)); int id2 = df.AddPolygon(Color.Black, DrawModes.DrawLines, new PointF(1000 + min.X * percent, -1 / f_tan * 1000 + min.Y * percent), new PointF(-1000 + min.X * percent, 1 / f_tan * 1000 + min.Y * percent)); //int id1 = df.AddPolygon(Color.Orange, DrawModes.DrawLines, // new PointF(1000 + max.X * percent, -1 / f_tan * 1000 + max.Y * percent), // new PointF(-1000 + max.X * percent, 1 / f_tan * 1000 + max.Y * percent)); //int id2 = df.AddPolygon(Color.CornflowerBlue, DrawModes.DrawLines, // new PointF(1000 + min.X * percent, -1 / f_tan * 1000 + min.Y * percent), // new PointF(-1000 + min.X * percent, 1 / f_tan * 1000 + min.Y * percent)); if (percent >= 0.99f) { break; } df.Update2(); Application.DoEvents(); df.RemoveGraphic(id2); df.RemoveGraphic(id1); } //df.AddPolygon(Color.Orange, 3f, DrawModes.DrawPoints, new PointF(max.X, max.Y)); //df.AddPolygon(Color.CornflowerBlue, 3f, DrawModes.DrawPoints, new PointF(min.X, min.Y)); df.AddPolygon(Color.Black, 3f, DrawModes.DrawPoints, new PointF(max.X, max.Y)); df.AddPolygon(Color.Black, 3f, DrawModes.DrawPoints, new PointF(min.X, min.Y)); df.Show(); df.Update2(); }
public static FractionPoint[] GetEmbracingPolygon(FractionPoint[] pts) { double[] keys = new double[pts.Length]; FractionPoint center = new FractionPoint(0, 0); for (int i = 0; i < pts.Length; i++) { center.X += pts[i].X / pts.Length; center.Y += pts[i].Y / pts.Length; } for (int i = 0; i < keys.Length; i++) { // fill keys with angles relative to center-point keys[i] = Math.Atan2(pts[i].Y - center.Y, pts[i].X - center.X); } Array.Sort <double, FractionPoint>(keys, pts); return(pts); }