lerp method

  1. @override
Matrix4 lerp (
  1. double t

Returns the value this variable has at the given animation clock value.

The default implementation of this method uses the +, -, and * operators on T. The begin and end properties must therefore be non-null by the time this method is called.

In general, however, it is possible for this to return null, especially when t=0.0 and begin is null, or t=1.0 and end is null.


Matrix4 lerp(double t) {
  assert(begin != null);
  assert(end != null);
  final Vector3 beginTranslation = Vector3.zero();
  final Vector3 endTranslation = Vector3.zero();
  final Quaternion beginRotation = Quaternion.identity();
  final Quaternion endRotation = Quaternion.identity();
  final Vector3 beginScale = Vector3.zero();
  final Vector3 endScale = Vector3.zero();
  begin.decompose(beginTranslation, beginRotation, beginScale);
  end.decompose(endTranslation, endRotation, endScale);
  final Vector3 lerpTranslation =
      beginTranslation * (1.0 - t) + endTranslation * t;
  // TODO(alangardner): Implement slerp for constant rotation
  final Quaternion lerpRotation =
      (beginRotation.scaled(1.0 - t) + endRotation.scaled(t)).normalized();
  final Vector3 lerpScale = beginScale * (1.0 - t) + endScale * t;
  return Matrix4.compose(lerpTranslation, lerpRotation, lerpScale);