length method
Calculates the approximate length of the cubic curve with a given accuracy
.
accuracy
A value between 0 (fastest, raw accuracy) and 1 (slowest, most accurate).
Returns the calculated length of the curve.
Implementation
double length({double accuracy = 0.1}) {
final steps = (accuracy * 100).toInt();
if (steps <= 1) {
return _distance;
}
double length = 0.0;
Offset prevPoint = start;
for (int i = 1; i < steps; i++) {
final t = i / steps;
final next = point(t);
length += prevPoint.distanceTo(next);
prevPoint = next;
}
return length;
}