@Test
public void testSlerp() {

  final Quaternion quat = new Quaternion();
  final Quaternion quat2 = new Quaternion().applyRotationY(MathUtils.HALF_PI);
  final Quaternion store = quat.slerp(quat2, .5, null);
  assertTrue(Math.abs(new Vector3(Math.sin(MathUtils.QUARTER_PI), 0, Math.sin(MathUtils.QUARTER_PI))
      .distance(store.apply(Vector3.UNIT_Z, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // delta == 100%
  quat2.setIdentity().applyRotationZ(MathUtils.PI);
  quat.slerp(quat2, 1.0, store);
  assertTrue(
      Math.abs(new Vector3(-1, 0, 0).distance(store.apply(Vector3.UNIT_X, null))) <= Quaternion.ALLOWED_DEVIANCE);
  quat2.setIdentity().applyRotationZ(MathUtils.PI);
  quat.slerp(quat2, .5, store);
  assertTrue(
      Math.abs(new Vector3(0, 1, 0).distance(store.apply(Vector3.UNIT_X, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // delta == 0%
  quat2.setIdentity().applyRotationZ(MathUtils.PI);
  quat.slerp(quat2, 0, store);
  assertTrue(
      Math.abs(new Vector3(1, 0, 0).distance(store.apply(Vector3.UNIT_X, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // a==b
  quat2.setIdentity();
  quat.slerp(quat2, 0.25, store);
  assertTrue(
      Math.abs(new Vector3(1, 0, 0).distance(store.apply(Vector3.UNIT_X, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // negative dot product
  quat.setIdentity().applyRotationX(-2 * MathUtils.HALF_PI);
  quat2.setIdentity().applyRotationX(MathUtils.HALF_PI);
  quat.slerp(quat2, 0.5, store);
  assertTrue(Math.abs(new Vector3(0, -Math.sin(MathUtils.QUARTER_PI), Math.sin(MathUtils.QUARTER_PI))
      .distance(store.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // LOCAL
  // delta == 100%
  quat2.setIdentity().applyRotationX(MathUtils.PI);
  quat.slerpLocal(quat2, 1.0);
  assertTrue(
      Math.abs(new Vector3(0, -1, 0).distance(quat.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
  quat.setIdentity();
  quat.slerpLocal(quat2, .5);
  assertTrue(
      Math.abs(new Vector3(0, 0, 1).distance(quat.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // delta == 0%
  quat.setIdentity();
  quat.slerpLocal(quat2, 0);
  assertTrue(
      Math.abs(new Vector3(0, 1, 0).distance(quat.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // a==b
  quat.setIdentity();
  quat2.setIdentity();
  quat.slerpLocal(quat2, 0.25);
  assertTrue(
      Math.abs(new Vector3(0, 1, 0).distance(quat.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
  // negative dot product
  quat.setIdentity().applyRotationX(-2 * MathUtils.HALF_PI);
  quat2.setIdentity().applyRotationX(MathUtils.HALF_PI);
  quat.slerpLocal(quat2, 0.5);
  assertTrue(Math.abs(new Vector3(0, -Math.sin(MathUtils.QUARTER_PI), Math.sin(MathUtils.QUARTER_PI))
      .distance(quat.apply(Vector3.UNIT_Y, null))) <= Quaternion.ALLOWED_DEVIANCE);
}