Exemplo n.º 1
0
        public Scene()
        {
            DataPoints = new List<PointD>();
            TargetBezier = new Bezier();
            CurrentBezier = new Bezier();

            MinDeviation = double.MaxValue;
        }
Exemplo n.º 2
0
 public static double CalcDeviation(List<PointD> data, Bezier b)
 {
     double sum = 0.0;
     foreach (var p in data)
     {
         double min_distance = double.MaxValue;
         for (double t = 0; t < 1.0; t += sample_interval)
         {
             double bx = Bezier(b.Point1.X, b.Point2.X, b.Point3.X, b.Point4.X, t), by = Bezier(b.Point1.Y, b.Point2.Y, b.Point3.Y, b.Point4.Y, t), dx = bx - p.X, dy = by - p.Y;
             double v = dx * dx + dy * dy;
             if (v < min_distance)
             {
                 min_distance = v;
             }
         }
         sum += min_distance;
     }
     return sum / data.Count;
 }
Exemplo n.º 3
0
        private void DrawBezier(Graphics graphics, Bezier bezier, Pen pen, Brush brush, bool control)
        {
            graphics.DrawBezier(pen, bezier.Point1.ToPointF(), bezier.Point2.ToPointF(), bezier.Point3.ToPointF(), bezier.Point4.ToPointF());
            if (control)
            {
                graphics.DrawLine(pen, bezier.Point1.ToPointF(), bezier.Point2.ToPointF());
                graphics.DrawLine(pen, bezier.Point4.ToPointF(), bezier.Point3.ToPointF());

                DrawPoint(graphics, bezier.Point1.X, bezier.Point1.Y, brush);
                DrawPoint(graphics, bezier.Point2.X, bezier.Point2.Y, brush);
                DrawPoint(graphics, bezier.Point3.X, bezier.Point3.Y, brush);
                DrawPoint(graphics, bezier.Point4.X, bezier.Point4.Y, brush);
            }
        }