예제 #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);
 }
예제 #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));
  }
예제 #3
0
 public void testRotateZYX() {
   Quaternionf v = new Quaternionf().rotateZYX(0.12f, 0.521f, 0.951f);
   Matrix4f m = new Matrix4f().rotateZYX(0.12f, 0.521f, 0.951f);
   Matrix4f n = new Matrix4f().set(v);
   TestUtil.assertMatrix4fEquals(m, n, 1E-6f);
 }