Search in sources :

Example 6 with Quaternion

use of org.rajawali3d.math.Quaternion in project Rajawali by Rajawali.

the class RotateAnimation3D method applyTransformation.

@Override
protected void applyTransformation() {
    Quaternion orientation = new Quaternion().slerp(mQuatFrom, mQuat, mInterpolatedTime, false);
    mTransformable3D.setOrientation(orientation);
}
Also used : Quaternion(org.rajawali3d.math.Quaternion)

Example 7 with Quaternion

use of org.rajawali3d.math.Quaternion in project Rajawali by Rajawali.

the class Vector3Test method testGetRotationTo.

@Test
public void testGetRotationTo() throws Exception {
    final Quaternion out = Vector3.X.getRotationTo(Vector3.Y);
    assertNotNull(out);
    assertEquals(0.7071067811865475, out.w, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out.x));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out.y));
    assertEquals(0.7071067811865475, out.z, 1e-14);
    final Quaternion out1 = Vector3.Y.getRotationTo(Vector3.Z);
    assertNotNull(out1);
    assertEquals(0.7071067811865475, out1.w, 1e-14);
    assertEquals(0.7071067811865475, out1.x, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out1.y));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out1.z));
    final Quaternion out2 = Vector3.X.getRotationTo(Vector3.Z);
    assertNotNull(out2);
    assertEquals(0.7071067811865475, out2.w, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out2.x));
    assertEquals(-0.7071067811865475, out2.y, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out2.z));
    final Quaternion out3 = Vector3.X.getRotationTo(Vector3.X);
    assertNotNull(out3);
    assertEquals(Double.doubleToRawLongBits(1d), Double.doubleToRawLongBits(out3.w));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out3.x));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out3.y));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out3.z));
    final Quaternion out4 = Vector3.X.getRotationTo(Vector3.NEG_X);
    assertNotNull(out4);
    assertEquals(0d, out4.w, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out4.x));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out4.y));
    assertEquals(Double.doubleToRawLongBits(-1d), Double.doubleToRawLongBits(out4.z));
}
Also used : Quaternion(org.rajawali3d.math.Quaternion) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Aggregations

Quaternion (org.rajawali3d.math.Quaternion)7 Vector3 (org.rajawali3d.math.vector.Vector3)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 Test (org.junit.Test)2 Object3D (org.rajawali3d.Object3D)2 Matrix4 (org.rajawali3d.math.Matrix4)2 AwdProperties (org.rajawali3d.loader.LoaderAWD.AwdProperties)1 BlockHeader (org.rajawali3d.loader.LoaderAWD.BlockHeader)1 ParsingException (org.rajawali3d.loader.ParsingException)1 Material (org.rajawali3d.materials.Material)1 Vector2 (org.rajawali3d.math.vector.Vector2)1