length property

double length

The approximate arc length of the curve.

The arc length is computed using a 30th order Legendre polynomial.

Implementation

double get length {
  final z = 0.5;
  final tValuesCount = legendrePolynomialRoots.length;
  var sum = 0.0;
  final cachedPoints = firstOrderDerivativePoints;
  for (var index = 0; index < tValuesCount; index++) {
    final t = z * legendrePolynomialRoots[index] + z;
    final d = derivativeAt(t, cachedFirstOrderDerivativePoints: cachedPoints);
    sum += legendrePolynomialWeights[index] * d.length;
  }
  return z * sum;
}