Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public MainForm()
 {
     InitializeComponent();
     converter = new ScreenConverter(ClientRectangle);
     _Axes     = new Axes(converter);
     _Segment  = new Segment(100, 100, 50,
                             0, 90);
     Invalidate();
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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;
                        }
                    }
                }
            }
        }
Пример #8
0
        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);
        }
Пример #9
0
 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));
 }
Пример #10
0
 public Axes(ScreenConverter c)
 {
     conv  = c;
     aFont = new Font("Arial", 7, FontStyle.Bold);
 }