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);
}
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));
}
Aggregations