getTangent method

  1. @override
Vector getTangent(
  1. num 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(num t, [Vector? optionalTarget]) {
		final tangent = optionalTarget ?? Vector3() ;
		final u = knots[ 0 ] + t * ( knots[knots.length - 1 ] - knots[ 0 ] );
		final ders = NURBSutils.calcNURBSDerivatives(degree, knots, controlPoints, u, 1 );
		tangent.setFrom( ders[ 1 ] ).normalize();
		return tangent;
	}