qlerp method

Quaternion qlerp(
  1. Quaternion qa,
  2. Quaternion qb,
  3. double t2
)

Returns a lerped quaternion based on theta.

Implementation

Quaternion qlerp(Quaternion qa, Quaternion qb, double t2) {
  Quaternion qm;
  double t1 = 1.0 - t2;
  qm = qa.scaled(t1) + qb.scaled(t2);
  double len = sqrt(qm.x * qm.x + qm.y * qm.y + qm.z * qm.z + qm.w * qm.w);
  qm.scale(1.0 - len);
  return qm;
}