public Point EndPoint(ScreenConverter s) { Point p = new Point(); p.X = (int)(s.II(Center.X) + R * Math.Cos((SweepAngle + StartAngle) * Math.PI / 180)); p.Y = (int)(s.JJ(Center.Y) + R * Math.Sin((SweepAngle + StartAngle) * Math.PI / 180)); return(p); }
public Point StartPoint(ScreenConverter s) { Point p = new Point(); p.X = (int)(s.II(Center.X) + R * Math.Cos(StartAngle * Math.PI / 180)); p.Y = (int)(s.JJ(Center.Y) + R * Math.Sin(StartAngle * Math.PI / 180));; return(p); }
public MainForm() { InitializeComponent(); converter = new ScreenConverter(ClientRectangle); _Axes = new Axes(converter); _Segment = new Segment(100, 100, 50, 0, 90); Invalidate(); }
public bool IsInside(Point pt, ScreenConverter conv) { int ptLength = Math.Abs((int)Math.Sqrt(Math.Pow(pt.X - conv.II(Center.X), 2) + Math.Pow(pt.Y - conv.JJ(Center.Y), 2))); if (ptLength >= 0 && ptLength <= R) { return(true); } return(false); }
public bool IsStart(Point pt, ScreenConverter conv) { int ptLength = Math.Abs((int)Math.Sqrt(Math.Pow(pt.X - StartPoint(conv).X, 2) + Math.Pow(pt.Y - StartPoint(conv).Y, 2))); if (ptLength >= 0 && ptLength <= R / 5) { return(true); } return(false); }
public bool IsEnd(Point pt, ScreenConverter conv) { int ptLength = (int)Math.Sqrt(Math.Pow(pt.X - EndPoint(conv).X, 2) + Math.Pow(pt.Y - EndPoint(conv).Y, 2)); if (ptLength >= 0 && ptLength <= R / 5) { return(true); } return(false); }
public void CalculateAngle(Point pt, ScreenConverter conv, bool start) { double x; double y; x = pt.X - conv.II(Center.X); y = pt.Y - conv.JJ(Center.Y); float alpha = (float)(Math.Atan2(y, x) * 180 / Math.PI); if (start) { StartAngle = alpha; } else { if (alpha < 0) { if (StartAngle > 90 && StartAngle < 180) { SweepAngle = 360 - StartAngle - Math.Abs(alpha); } else { SweepAngle = 360 - StartAngle - Math.Abs(alpha); if (SweepAngle > 360) { SweepAngle = SweepAngle % 360; } } } else { if (StartAngle > 90 && StartAngle < 180) { SweepAngle = 360 + alpha - StartAngle; SweepAngle = SweepAngle % 360; } else { if (StartAngle < 0) { SweepAngle = -StartAngle + alpha; } else { SweepAngle = alpha; } } } } }
public static Bitmap Draw(Bitmap bmp, Segment s, ScreenConverter conv) { Graphics g = Graphics.FromImage(bmp); g.DrawArc(Pens.Black, conv.II(s.Center.X) - s.R, conv.JJ(s.Center.Y) - s.R, s.R * 2, s.R * 2, s.StartAngle, s.SweepAngle); g.DrawEllipse(Pens.Black, s.StartPoint(conv).X - s.R / 10, s.StartPoint(conv).Y - s.R / 10, s.R / 5, s.R / 5); g.DrawEllipse(Pens.Black, s.EndPoint(conv).X - s.R / 10, s.EndPoint(conv).Y - s.R / 10, s.R / 5, s.R / 5); if (!(s.StartAngle == 0 && s.SweepAngle == 360)) { g.DrawLine(Pens.Black, s.StartPoint(conv), s.EndPoint(conv)); } g.Dispose(); return(bmp); }
public void CalculateRadius(Point pt, ScreenConverter conv) { R = (float)Math.Sqrt(Math.Pow(pt.X - conv.II(Center.X), 2) + Math.Pow(pt.Y - conv.JJ(Center.Y), 2)); }
public Axes(ScreenConverter c) { conv = c; aFont = new Font("Arial", 7, FontStyle.Bold); }