Exemple #1
0
        /// <summary>
        /// Calculates the length of the specified bezier curve.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="precision">The precision value.</param>
        /// <param name="parallel">The parallel value.</param>
        /// <returns>Length of curve.</returns>
        /// <remarks><para>The precision gets better as the <paramref name="precision"/>
        /// value gets smaller.</para>
        /// <para>The <paramref name="parallel"/> parameter defines whether the curve should be calculated as a
        /// parallel curve to the original bezier curve. A value of 0.0f represents
        /// the original curve, 5.0f represents a curve that has always a distance
        /// of 5.0f to the orignal curve.</para></remarks>
        public static float CalculateLength(IList <Vector2> points, float precision, float parallel)
        {
            float   length = 0.0f;
            Vector2 old    = BezierCurve.CalculatePoint(points, 0.0f, parallel);

            for (float i = precision; i < (1.0f + precision); i += precision)
            {
                Vector2 n = CalculatePoint(points, i, parallel);
                length += (n - old).Length;
                old     = n;
            }

            return(length);
        }
Exemple #2
0
 /// <summary>
 /// Calculates the point on the given bezier curve with the specified t parameter.
 /// </summary>
 /// <param name="points">The points.</param>
 /// <param name="t">The t parameter, a value between 0.0f and 1.0f.</param>
 /// <returns>Resulting point.</returns>
 public static Vector2 CalculatePoint(IList <Vector2> points, float t)
 {
     return(BezierCurve.CalculatePoint(points, t, 0.0f));
 }
Exemple #3
0
 /// <summary>
 /// Calculates the point with the specified t.
 /// </summary>
 /// <param name="t">The t value, between 0.0f and 1.0f.</param>
 /// <returns>Resulting point.</returns>
 public Vector2 CalculatePoint(float t)
 {
     return(BezierCurve.CalculatePoint(points, t, Parallel));
 }