Esempio n. 1
0
 public sRect(DelegateContainer _dlc, Point Down, Point Up)
     : base(_dlc)
 {
     this.Up = base.dlc.fScreenToReal(Down);
     this.Down = base.dlc.fScreenToReal(Up);
 }
Esempio n. 2
0
 public sRect(DelegateContainer _dlc, double x1, double y1, double x2, double y2)
     : base(_dlc)
 {
     this.Up = new fpoint(x1, y1);
     this.Down = new fpoint(x2, y2);
 }
Esempio n. 3
0
 public sLine(DelegateContainer _dlc, double x1, double y1, double x2, double y2)
     : base(_dlc)
 {
     fpBeg = new fpoint(x1, y1);
     fpEnd = new fpoint(x2, y2);
 }
Esempio n. 4
0
        public override double GetR(fpoint f)
        {
            fpoint bp;
            fpoint cp;

            if (fpoint.GetRasst(f, fpEnd) > fpoint.GetRasst(f, fpBeg))
            {
                bp = fpEnd - fpBeg;
                cp = f - fpBeg;
            }
            else
            {
                bp = fpBeg - fpEnd;
                cp = f - fpEnd;
            }

            double a = fpoint.GetRasstNormalized(cp);
            double b = fpoint.GetRasstNormalized(bp);
            double cosa = (bp.x * cp.x + bp.y * cp.y) / (a * b);
            double res = cosa >= 0 ? Math.Sqrt(1 - cosa * cosa) * a : -1;

            return res < 50 ? res : -1;
        }
Esempio n. 5
0
 //Длина вектора с началом в точке (0,0)
 public static double GetRasstNormalized(fpoint a)
 {
     return(Math.Sqrt(a.x * a.x + a.y * a.y));
 }
Esempio n. 6
0
 public sLine(DelegateContainer _dlc, Point p1, Point p2)
     : base(_dlc)
 {
     fpBeg = base.dlc.fScreenToReal(p1);
     fpEnd = base.dlc.fScreenToReal(p2);
 }
Esempio n. 7
0
 public sCross(DelegateContainer _dlc, double x, double y)
     : base(_dlc)
 {
     Center = new fpoint(x, y);
 }
Esempio n. 8
0
 public sCircle(DelegateContainer _dlc, Point Down, Point Up)
     : base(_dlc)
 {
     this.Center = base.dlc.fScreenToReal(Down);
     this.Radius = fpoint.GetRasst(base.dlc.fScreenToReal(Down), base.dlc.fScreenToReal(Up));
 }
Esempio n. 9
0
 public override double GetR(fpoint f)
 {
     double val = fpoint.GetRasst(Center, f);
     return val < Radius ? val : -1;
 }
Esempio n. 10
0
 public sCross(DelegateContainer _dlc, int x, int y)
     : base(_dlc)
 {
     Center = base.dlc.fScreenToReal(new Point(x, y));
 }
Esempio n. 11
0
 //переводит истинны координаты в экранные
 public Point RealToScreen(fpoint pt)
 {
     try
     {
         return new Point(Convert.ToInt32(pt.x * rs_dx), Convert.ToInt32(pt.y * rs_dy));
     }
     catch (Exception e)
     {
         onException("Ошибка при преобразовании координаты", e.Message);
         return new Point();
     }
 }
Esempio n. 12
0
 //Длина вектора с началом в точке (0,0)
 public static double GetRasstNormalized(fpoint a)
 {
     return Math.Sqrt(a.x * a.x + a.y * a.y);
 }
Esempio n. 13
0
 //Расстояние между двумя точками
 public static double GetRasst(fpoint a, fpoint b)
 {
     return Math.Sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
 }
Esempio n. 14
0
        public override double GetR(fpoint f)
        {
            fpoint a;
            fpoint b;
            WHRect(out a, out b);

            if ((f.x > a.x) && (f.y > a.y) && (f.x < b.x) && (f.y < b.y)) return 10;
            return -1;
        }
Esempio n. 15
0
 public override double GetR(fpoint f)
 {
     double val = fpoint.GetRasst(this.Center, f);
     return val < 50 ? val: -1;
 }
Esempio n. 16
0
        private void WHRect(out fpoint a, out fpoint b)
        {
            fpoint uppoint;
            fpoint dwpoint;

            if (Up.y < Down.y)
            {
                uppoint = Up;
                dwpoint = Down;
            }
            else
            {
                uppoint = Down;
                dwpoint = Up;
            }

            if (uppoint.x > dwpoint.x)
            {
                double temp = dwpoint.y;
                dwpoint.y = uppoint.y;
                uppoint.y = temp;

                fpoint tmp = dwpoint;
                dwpoint = uppoint;
                uppoint = tmp;
            }

            a = uppoint;
            b = dwpoint;
        }
Esempio n. 17
0
 //Получает расстояние от данной точки до фигуры
 public abstract double GetR(fpoint f);
Esempio n. 18
0
 public sCircle(DelegateContainer _dlc, double x1, double y1, double r)
     : base(_dlc)
 {
     this.Center = new fpoint(x1, y1);
     this.Radius = r;
 }
Esempio n. 19
0
 //Расстояние между двумя точками
 public static double GetRasst(fpoint a, fpoint b)
 {
     return(Math.Sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
 }