public static float GetApproximateLengthOfCubicCurve(Vector3 startPosition, Vector3 endPosition, Vector3 startTangent, Vector3 endTangent, int sampling)
{
float length = 0f;
Vector3 fromPoint = GetPointOnCubicCurve(0f, startPosition, endPosition, startTangent, endTangent);
for (int i = 0; i < sampling; i++)
{
float time = (i + 1) / (float)sampling;
Vector3 toPoint = GetPointOnCubicCurve(time, startPosition, endPosition, startTangent, endTangent);
length += Vector3.Distance(fromPoint, toPoint);
fromPoint = toPoint;
}
return length;
}