Example #1
0
        protected void CalculateAngle()
        {
            //Create line from the base of the whisker to the point on the whisker
            IWhiskerPoint baseWhiskerPoint = ControlPoints.Last();

            BasePoint = new Point(baseWhiskerPoint.XRatio * VideoWidth, baseWhiskerPoint.YRatio * VideoHeight);
            Point  anglePoint;
            Vector gradient;

            if (TValue == 1)
            {
                //If TValue == 1 (Point on whisker == base), calculate gradient at TValue = 1
                gradient      = GetBezierGradientVideoSize();
                gradient     *= -1;
                anglePoint    = BasePoint;
                anglePoint.X += gradient.X;
                anglePoint.Y += gradient.Y;
            }
            else
            {
                anglePoint = GetTValuePoint();
                gradient   = new Vector(anglePoint.X - BasePoint.X, anglePoint.Y - BasePoint.Y);
            }

            //Create line which will determine angle
            gradient.Normalize();
            TargetPoint = anglePoint;

            AngleLine = gradient;
            Angle     = AngleType.CalculateAngle(AngleLine);
        }