derivativeAt method
Vector2
derivativeAt(})
override
Returns the tangent vector at parameter t
.
The return value is not normalized. The optional parameter cachedFirstOrderDerivativePoints
allows the method to use previously calculated values for firstOrderDerivativePoints instead
of repeating the calculations.
Implementation
@override
Vector2 derivativeAt(double t,
{List<Vector2>? cachedFirstOrderDerivativePoints}) {
final derivativePoints =
cachedFirstOrderDerivativePoints ?? firstOrderDerivativePoints;
final mt = 1.0 - t;
final a = mt * mt;
final b = 2.0 * mt * t;
final c = t * t;
final localDerivative = Vector2.copy(derivativePoints[0]);
localDerivative.scale(a);
localDerivative.addScaled(derivativePoints[1], b);
localDerivative.addScaled(derivativePoints[2], c);
return localDerivative;
}