slerp method

Vector slerp (
  1. Vector vec,
  2. num t
)

Implementation

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

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

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