Ejemplo n.º 1
0
 public void testNlerpRecursive() {
   Quaternionf q1 = new Quaternionf().rotateY(0.0f);
   Quaternionf q2 = new Quaternionf().rotateY((float) Math.PI);
   Quaternionf q = new Quaternionf();
   Vector3f v = new Vector3f(1.0f, 0.0f, 0.0f);
   q1.nlerpIterative(q2, 0.5f, 1E-5f, q);
   q.transform(v);
   TestUtil.assertVector3fEquals(new Vector3f(0.0f, 0.0f, 1.0f), v, 1E-5f);
 }
Ejemplo n.º 2
0
  public void testMulQuaternionQuaternionQuaternion() {
    // Multiplication with the identity quaternion should change nothing
    Quaternionf testQuat = new Quaternionf(1f, 23.3f, -7.57f, 2.1f);
    Quaternionf identityQuat = new Quaternionf().identity();
    Quaternionf resultQuat = new Quaternionf();

    testQuat.mul(identityQuat, resultQuat);
    assertTrue(
        TestUtil.quatEqual(testQuat, resultQuat, TestUtil.STANDARD_AROUND_ZERO_PRECISION_FLOAT));

    identityQuat.mul(testQuat, resultQuat);
    assertTrue(
        TestUtil.quatEqual(testQuat, resultQuat, TestUtil.STANDARD_AROUND_ZERO_PRECISION_FLOAT));

    // Multiplication with conjugate should give (0, 0, 0, dot(this, this))
    Quaternionf conjugate = new Quaternionf();
    testQuat.conjugate(conjugate);
    testQuat.mul(conjugate, resultQuat);

    Quaternionf wantedResultQuat = new Quaternionf(0, 0, 0, testQuat.dot(testQuat));
    assertTrue(
        TestUtil.quatEqual(
            resultQuat, wantedResultQuat, TestUtil.MANY_OPS_AROUND_ZERO_PRECISION_FLOAT));
  }
Ejemplo n.º 3
0
 public void testRotateToReturnsDestination() {
   Quaternionf rotation = new Quaternionf();
   Quaternionf destination = new Quaternionf();
   Quaternionf result = rotation.rotateTo(0, 1, 0, 0, 1, 0, destination);
   assertSame(destination, result);
 }