/// <summary> /// kruznice urcena tremi body na obvodu /// </summary> /// <param name="pt1">prvni bod</param> /// <param name="pt2">druhy bod</param> /// <param name="pt3">treti bod</param> public Circle2D(Point pt1, Point pt2, Point pt3) { Radius = 0; Center = pt1; Point[] p = new Point[2]; Vector[] v = new Vector[2]; p[0].X = (pt1.X + pt2.X) / 2; p[0].Y = (pt1.Y + pt2.Y) / 2; p[1].X = (pt2.X + pt3.X) / 2; p[1].Y = (pt2.Y + pt3.Y) / 2; v[0].X = pt2.Y - pt1.Y; v[0].Y = -(pt2.X - pt1.X); v[1].X = pt3.Y - pt2.Y; v[1].Y = -(pt3.X - pt2.X); TwoLine2D.CrossStatus st = TwoLine2D.CrossStatus.Infinite; if (TwoLine2D.CrossAbs(p[0], st, v[0], st, p[1], st, v[1], st, out Center)) { Radius = Funcs2D.Distance(pt1, Center); } }
private Object[] f_MakeCross() { Object[] ret = new Object[2]; List <Point> retPt = new List <Point>(); List <int> retInx = new List <int>(); Point[] bln = null, eln; // ofsetovane usecky int b, m, e, len; if (IsClosed) { b = mySrc.Length - 1; m = 0; len = mySrc.Length; } else { b = 0; m = 1; len = mySrc.Length - 1; } for (; m < len; m++) { e = m + 1; if (e == mySrc.Length) { e = 0; } // test totoznych bodu if (Funcs2D.IsEqual(mySrc[b].Pt, mySrc[m].Pt, Funcs2D.Epson)) { b = m; continue; // vynecham } // test tri body na jedne primce if (Funcs2D.IsThreePointsOnLine(mySrc[b].Pt, mySrc[m].Pt, mySrc[e].Pt, Funcs2D.Epson)) { b = m; continue; // vynecham } //vypocitam offsety if (bln == null) { bln = Funcs2D.LineOffset(mySrc[b].Pt, mySrc[m].Pt, mySrc[b].Offset); } eln = Funcs2D.LineOffset(mySrc[m].Pt, mySrc[e].Pt, mySrc[m].Offset); if (!IsClosed && b == 0) { retPt.Add(bln[0]); retInx.Add(0); } // prusecik TwoLine2D.CrossAbs(bln[0], bln[1], eln[0], eln[1], TwoLine2D.CrossStatus.Infinite, out Point rpt); retPt.Add(rpt); retInx.Add(m); if (!IsClosed && e == len) { retPt.Add(eln[1]); retInx.Add(len); } b = m; bln = eln; } if (len == 1) { bln = Funcs2D.LineOffset(mySrc[b].Pt, mySrc[m].Pt, mySrc[b].Offset); retPt.Add(bln[0]); retInx.Add(0); retPt.Add(bln[1]); retInx.Add(1); } ret[0] = retPt; ret[1] = retInx; return(ret); }