Vector slerp(Vector vec, num t)

Source

Vector slerp(Vector vec, num t) {
  num cosTheta = this.dot(vec);
  num theta = acos(cosTheta);
  num sinTheta = sin(theta);

  if (sinTheta <= Epsilon)
    return vec.clone();

  num w1 = sin((1 - t) * theta) / sinTheta;
  num w2 = sin(t * theta) / sinTheta;
  return this.scale(w1) + vec.scale(w2);
}