public void TestMethodLineFitted() { Random rnd = new Random(DateTime.Now.Millisecond); //generate point set alone one line (10 points List <ElementBase> pSet = new List <ElementBase>(); PointBase start = new PointBase(new List <ElementBase> { c1 }); start.Point = new Mat(3, 1, MatType.CV_64FC1, new double[] { 0, 0, 1 }); for (int i = 0; i < 10; i++) { PointBase next = new PointBase(new List <ElementBase> { c1 }); next.Point = start.Point + l0055.Vector * i + new Mat(3, 1, MatType.CV_64FC1, new double[] { rnd.NextDouble() - 1, rnd.NextDouble() - 1, 1 }); pSet.Add(next); } LineFitted lf = new LineFitted(pSet); Trace.WriteLine(lf.Coefficient()); }
/// <summary> /// Improvement , use Factory pattern as generized interface /// </summary> /// <param name="selection"></param> /// <param name="add"></param> /// <returns></returns> public LineFitted FitLine(List <SnapBase> selection, bool add) { LineFitted line = new LineFitted(); line.__selectedPoints = selection; line.Update(); if (add) { activeLayer.Add(line); } return(line); }