Beispiel #1
0
        /// <summary>
        /// Determine and store the length of each curve segment along the whole path
        ///
        /// Assumption:
        ///     points has 3*n+1 points in it.
        ///
        /// </summary>
        private void FillInSegmentLengths()
        {
            if (lengthRatios == null)
            {
                throw new Exception("lengthRatios must be defined assigned before calling FillInEndTangents");
            }

            pathLength = 0;

            for (int i = 0; i < segmentCount; i++)
            {
                LengthRatio lr = new LengthRatio();

                lr.length =
                    BezierSprite.CalculateCurveLength(
                        points.GetRange(i * 3, 4).ToArray()                         // there are 4 points to each segment. * 3 because we start each next segment with the end point of the previous segment
                        );

                lr.ratio        = defaultRatio;          // default value since we haven't calc'd ratios yet
                lengthRatios[i] = lr;

                pathLength += lr.length;                 // calc length of whole path
            }
        }