/// <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);
}