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 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 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); }
void OX()//ось х { g.DrawLine(Pens.LightBlue, conv.II(conv.x1), conv.JJ(0), conv.II(conv.x2), conv.JJ(0)); double h1 = HH(conv.x1, conv.x2); int k1 = (int)Math.Round(conv.x1 / h1) - 1; int k2 = (int)Math.Round(conv.x2 / h1); byte Digits = GetDigits(Math.Abs(conv.x2 - conv.x1)); for (int i = k1; i <= k2; i++) { g.DrawLine(MyPen2, conv.II(i * h1), conv.JJ(0) - 7, conv.II(i * h1), conv.JJ(0) + 7); for (int j = 1; j <= 9; j++) { g.DrawLine(MyPen2, conv.II(i * h1 + j * h1 / 10), conv.JJ(0) - 3, conv.II(i * h1 + j * h1 / 10), conv.JJ(0) + 3); } string s = Convert.ToString(Math.Round(h1 * i, Digits)); g.DrawString(s, aFont, Brushes.Black, conv.II(i * h1) - 5, conv.JJ(0) - 13); } }