function slerp(out, a, b, t) {
      // benchmarks:
      //    http://jsperf.com/quaternion-slerp-implementations
      var ax = a[0],
          ay = a[1],
          az = a[2],
          aw = a[3];
      var bx = b[0],
          by = b[1],
          bz = b[2],
          bw = b[3];
      var omega, cosom, sinom, scale0, scale1; // calc cosine

      cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)

      if (cosom < 0.0) {
        cosom = -cosom;
        bx = -bx;
        by = -by;
        bz = -bz;
        bw = -bw;
      } // calculate coefficients


      if (1.0 - cosom > EPSILON) {
        // standard case (slerp)
        omega = Math.acos(cosom);
        sinom = Math.sin(omega);
        scale0 = Math.sin((1.0 - t) * omega) / sinom;
        scale1 = Math.sin(t * omega) / sinom;
      } else {
        // "from" and "to" quaternions are very close
        //  ... so we can do a linear interpolation
        scale0 = 1.0 - t;
        scale1 = t;
      } // calculate final values


      out[0] = scale0 * ax + scale1 * bx;
      out[1] = scale0 * ay + scale1 * by;
      out[2] = scale0 * az + scale1 * bz;
      out[3] = scale0 * aw + scale1 * bw;
      return out;
    }
/**
     * Performs a spherical linear interpolation between two quat
     *
     * @param {quat} out the receiving quaternion
     * @param {ReadonlyQuat} a the first operand
     * @param {ReadonlyQuat} b the second operand
     * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
     * @returns {quat} out
     */
Performs a spherical linear interpolation between two quat


Performs a spherical linear interpolation between two quat
function slerp(out, a, b, t) {
      var ax = a[0],
          ay = a[1],
          az = a[2],
          aw = a[3];
      var bx = b[0],
          by = b[1],
          bz = b[2],
          bw = b[3];
      var omega, cosom, sinom, scale0, scale1; 
      cosom = ax * bx + ay * by + az * bz + aw * bw; 
      if (cosom < 0.0) {
        cosom = -cosom;
        bx = -bx;
        by = -by;
        bz = -bz;
        bw = -bw;
      } 
      if (1.0 - cosom > EPSILON) {
        omega = Math.acos(cosom);
        sinom = Math.sin(omega);
        scale0 = Math.sin((1.0 - t) * omega) / sinom;
        scale1 = Math.sin(t * omega) / sinom;
      } else {
        scale0 = 1.0 - t;
        scale1 = t;
      } 
      out[0] = scale0 * ax + scale1 * bx;
      out[1] = scale0 * ay + scale1 * by;
      out[2] = scale0 * az + scale1 * bz;
      out[3] = scale0 * aw + scale1 * bw;
      return out;
    }
function slerp ( out , a , b , t ) { var ax = a [ 0 ] , ay = a [ 1 ] , az = a [ 2 ] , aw = a [ 3 ] ; var bx = b [ 0 ] , by = b [ 1 ] , bz = b [ 2 ] , bw = b [ 3 ] ; var omega , cosom , sinom , scale0 , scale1 ; cosom = ax * bx + ay * by + az * bz + aw * bw ; if ( cosom < 0.0 ) { cosom = - cosom ; bx = - bx ; by = - by ; bz = - bz ; bw = - bw ; } if ( 1.0 - cosom > EPSILON ) { omega = Math . acos ( cosom ) ; sinom = Math . sin ( omega ) ; scale0 = Math . sin ( ( 1.0 - t ) * omega ) / sinom ; scale1 = Math . sin ( t * omega ) / sinom ; } else { scale0 = 1.0 - t ; scale1 = t ; } out [ 0 ] = scale0 * ax + scale1 * bx ; out [ 1 ] = scale0 * ay + scale1 * by ; out [ 2 ] = scale0 * az + scale1 * bz ; out [ 3 ] = scale0 * aw + scale1 * bw ; return out ; }
Performs a spherical linear interpolation between two quat
Performs a spherical linear interpolation between two quat
// benchmarks: //    http://jsperf.com/quaternion-slerp-implementations // calc cosine // adjust signs (if necessary) // calculate coefficients // standard case (slerp) // "from" and "to" quaternions are very close //  ... so we can do a linear interpolation // calculate final values