public sRect(DelegateContainer _dlc, Point Down, Point Up) : base(_dlc) { this.Up = base.dlc.fScreenToReal(Down); this.Down = base.dlc.fScreenToReal(Up); }
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); }
public sLine(DelegateContainer _dlc, double x1, double y1, double x2, double y2) : base(_dlc) { fpBeg = new fpoint(x1, y1); fpEnd = new fpoint(x2, y2); }
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; }
//Длина вектора с началом в точке (0,0) public static double GetRasstNormalized(fpoint a) { return(Math.Sqrt(a.x * a.x + a.y * a.y)); }
public sLine(DelegateContainer _dlc, Point p1, Point p2) : base(_dlc) { fpBeg = base.dlc.fScreenToReal(p1); fpEnd = base.dlc.fScreenToReal(p2); }
public sCross(DelegateContainer _dlc, double x, double y) : base(_dlc) { Center = new fpoint(x, y); }
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)); }
public override double GetR(fpoint f) { double val = fpoint.GetRasst(Center, f); return val < Radius ? val : -1; }
public sCross(DelegateContainer _dlc, int x, int y) : base(_dlc) { Center = base.dlc.fScreenToReal(new Point(x, y)); }
//переводит истинны координаты в экранные 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(); } }
//Длина вектора с началом в точке (0,0) public static double GetRasstNormalized(fpoint a) { return Math.Sqrt(a.x * a.x + a.y * a.y); }
//Расстояние между двумя точками 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)); }
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; }
public override double GetR(fpoint f) { double val = fpoint.GetRasst(this.Center, f); return val < 50 ? val: -1; }
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; }
//Получает расстояние от данной точки до фигуры public abstract double GetR(fpoint f);
public sCircle(DelegateContainer _dlc, double x1, double y1, double r) : base(_dlc) { this.Center = new fpoint(x1, y1); this.Radius = r; }
//Расстояние между двумя точками 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))); }