Пример #1
0
        private void AddBezierByNURBS(List <GPoint> points)
        {
            if (points.Count() < 3)
            {
                return;
            }

            int degree = points.Count - 1;
            var ls     = new OxyPlot.Series.LineSeries()
            {
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Plus,
                MarkerStroke = OxyPlot.OxyColors.Blue
            };

            double duration = Util.Util.MeasureExecTime(() =>
            {
                const int INTERVAL_NUM = 100;
                double step            = 1.0 / INTERVAL_NUM;
                NURBSCurve bspline     = new NURBSCurve(points, degree);
                for (double t = 0; t < 1.0; t += step)
                {
                    GPoint p = bspline.NonRationalBSpline(t);
                    ls.Points.Add(new OxyPlot.DataPoint(p.X, p.Y));
                }
            });

            ls.Title = $"NURBS(Bezier-{degree})({duration:0.###}ms)";
            base.Series.Add(ls);
        }
Пример #2
0
        private void AddBSplineByNURBS(List <GPoint> points, double curveLength)
        {
            if (points.Count() < 3)
            {
                return;
            }

            var ls = new OxyPlot.Series.LineSeries()
            {
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Plus,
                MarkerStroke = OxyPlot.OxyColors.Blue
            };

            int    degree   = SplineDegree(points);
            double duration = Util.Util.MeasureExecTime(() =>
            {
                NURBSCurve bspline = new NURBSCurve(points, degree);
                for (double u = 0; u <= 1.0; u += 0.01)
                {
                    GPoint p = bspline.NonRationalBSpline(u);
                    ls.Points.Add(new OxyPlot.DataPoint(p.X, p.Y));
                }
            });

            ls.Title = $"NURBS({degree})[len={curveLength:0.#}]({duration:0.###}ms)";
            base.Series.Add(ls);
        }