getTangent method

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

t - A position on the curve. Must be in the range 0, 1 .

optionalTarget — (optional) If specified, the result will be copied into this Vector, otherwise a new Vector will be created.

Returns a unit vector tangent at t. If the derived curve does not implement its tangent derivation, two points a small delta apart will be used to find its gradient which seems to give a reasonable approximation.

Implementation

@override
Vector getTangent(double t, [Vector? optionalTarget]) {
  final tangent = optionalTarget ?? Vector2();
  tangent.setFrom(v2).sub(v1).normalize();
  return tangent;
}