Esempio n. 1
0
        private void CalculateCurvature()
        {
            Curvature = 0;

            if (ControlPoints.Length == 2)
            {
                TargetPoint = GetTValuePointForLinear();
            }
            else if (ControlPoints.Length == 3)
            {
                IWhiskerPoint cWhiskerPoint0 = Whisker.WhiskerPoints[0];
                IWhiskerPoint cWhiskerPoint1 = Whisker.WhiskerPoints[1];
                IWhiskerPoint cWhiskerPoint2 = Whisker.WhiskerPoints[2];

                Point[] points = new Point[3];
                points[0] = new Point(cWhiskerPoint0.XRatio * VideoWidth, cWhiskerPoint0.YRatio * VideoHeight);
                points[1] = new Point(cWhiskerPoint1.XRatio * VideoWidth, cWhiskerPoint1.YRatio * VideoHeight);
                points[2] = new Point(cWhiskerPoint2.XRatio * VideoWidth, cWhiskerPoint2.YRatio * VideoHeight);

                Curvature = DrawingUtility.GetQuadraticBezierCurvature(points, TValue);

                TargetPoint = GetTValuePointForQuadratic();
            }
            else
            {
                IWhiskerPoint cWhiskerPoint0 = Whisker.WhiskerPoints[0];
                IWhiskerPoint cWhiskerPoint1 = Whisker.WhiskerPoints[1];
                IWhiskerPoint cWhiskerPoint2 = Whisker.WhiskerPoints[2];
                IWhiskerPoint cWhiskerPoint3 = Whisker.WhiskerPoints[3];

                Point[] points = new Point[4];
                points[0] = new Point(cWhiskerPoint0.XRatio * VideoWidth, cWhiskerPoint0.YRatio * VideoHeight);
                points[1] = new Point(cWhiskerPoint1.XRatio * VideoWidth, cWhiskerPoint1.YRatio * VideoHeight);
                points[2] = new Point(cWhiskerPoint2.XRatio * VideoWidth, cWhiskerPoint2.YRatio * VideoHeight);
                points[3] = new Point(cWhiskerPoint3.XRatio * VideoWidth, cWhiskerPoint3.YRatio * VideoHeight);

                Curvature   = DrawingUtility.GetCubicBezierCurvature(points, TValue);
                TargetPoint = GetTValuePointForCubic();
            }
        }