getPoint method

  1. @override
Vector? getPoint(
  1. double t, [
  2. Vector? optionalTarget
])
override

Implementation

@override
Vector? getPoint(double t, [Vector? optionalTarget]) {
  final d = t * getLength();
  final curveLengths = getCurveLengths();
  int i = 0;

  // To think about boundaries points.

  while (i < curveLengths.length) {
    if (curveLengths[i] >= d) {
      final diff = curveLengths[i] - d;
      final curve = curves[i];

      final segmentLength = curve.getLength();
      final double u = segmentLength == 0 ? 0 : 1 - diff / segmentLength;

      return curve.getPointAt(u, optionalTarget);
    }

    i++;
  }

  return null;

  // loop where sum != 0, sum > d , sum+1 <d
}