public CCBezierSpline Clone()
        {
            CCBezierSpline myResult = new CCBezierSpline();

            myResult.BeginEditSpline();
            _myPoints.ForEach(p => myResult._myPoints.Add(p));
            myResult.EndEditSpline();
            return(myResult);
        }
        /// <summary>
        /// Interpolate a position on the spline </summary>
        /// <param name="theBlend"> a value from 0 to 1 that represent the position between the first control point and the last one </param>
        /// <returns> the position </returns>
        public virtual CCBezierSpline SubSpline(float theBlendA, float theBlendB)
        {
            if (_myPoints.Count == 0)
            {
                return(null);
            }
            if (_mySegmentsLength == null || _mySegmentsLength.Count == 0)
            {
                return(null);
            }


            float myLocalBlendA;
            int   indexA = InterpolationValues(theBlendA, out myLocalBlendA) * _myInterpolationIncrease;
            float myLocalBlendB;
            int   indexB = InterpolationValues(theBlendB, out myLocalBlendB) * _myInterpolationIncrease;

            Vector3 inControlA;
            Vector3 anchorA;
            Vector3 outControlA;

            Bezier(_myPoints[indexA], _myPoints[indexA + 1], _myPoints[indexA + 2], _myPoints[indexA + 3], myLocalBlendA, out inControlA, out anchorA, out outControlA);

            CCBezierSpline myResult = new CCBezierSpline();

            myResult.BeginEditSpline();
            myResult._myPoints.Add(anchorA);

            if (indexA == indexB)
            {
                myResult._myPoints.Add(Vector3.Lerp(anchorA, outControlA, myLocalBlendB));
            }
            else
            {
                myResult._myPoints.Add(outControlA);
            }

            if (indexB > indexA + 3)
            {
                Vector3 inControlA0  = _myPoints[indexA + 3 - 1];
                Vector3 anchorA0     = _myPoints[indexA + 3];
                Vector3 outControlA0 = _myPoints[indexA + 3 + 1];

                myResult._myPoints.Add(Vector3.Lerp(inControlA0, anchorA0, myLocalBlendA));
                myResult._myPoints.Add(anchorA0);
                myResult._myPoints.Add(outControlA0);


                for (int i = indexA + 6; i < indexB; i += 3)
                {
                    Vector3 inControl  = _myPoints[i - 1];
                    Vector3 anchor     = _myPoints[i];
                    Vector3 outControl = _myPoints[i + 1];

                    myResult._myPoints.Add(inControl);
                    myResult._myPoints.Add(anchor);
                    myResult._myPoints.Add(outControl);
                }

                Vector3 inControlB0  = _myPoints[indexB - 1];
                Vector3 anchorB0     = _myPoints[indexB];
                Vector3 outControlB0 = _myPoints[indexB + 1];

                myResult._myPoints.Add(inControlB0);
                myResult._myPoints.Add(anchorB0);
                myResult._myPoints.Add(Vector3.Lerp(anchorB0, outControlB0, myLocalBlendB));
            }
            else if (indexB == indexA + 3)
            {
                Vector3 inControlA0  = _myPoints[indexA + 3 - 1];
                Vector3 anchorA0     = _myPoints[indexA + 3];
                Vector3 outControlA0 = _myPoints[indexA + 3 + 1];

                myResult._myPoints.Add(Vector3.Lerp(inControlA0, anchorA0, myLocalBlendA));
                myResult._myPoints.Add(anchorA0);
                myResult._myPoints.Add(Vector3.Lerp(anchorA0, outControlA0, myLocalBlendB));
            }

            Vector3 inControlB;
            Vector3 anchorB;
            Vector3 outControlB;

            Bezier(_myPoints[indexB], _myPoints[indexB + 1], _myPoints[indexB + 2], _myPoints[indexB + 3], myLocalBlendB, out inControlB, out anchorB, out outControlB);

            if (indexA == indexB)
            {
                myResult._myPoints.Add(Vector3.Lerp(inControlB, anchorB, myLocalBlendA));
            }
            else
            {
                myResult._myPoints.Add(inControlB);
            }
            myResult._myPoints.Add(anchorB);

            myResult.EndEditSpline();
            return(myResult);
        }