Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQuaternion, Poolable { @Override public Quaternion multiply(final double scalar, final Quaternion store) { Quaternion result = store; if (result == null) { result = new Quaternion(); } return result.set(scalar * getX(), scalar * getY(), scalar * getZ(), scalar * getW()); } Quaternion();  Quaternion(final ReadOnlyQuaternion source);  Quaternion(final double x, final double y, final double z, final double w); @Override double getX(); @Override double getY(); @Override double getZ(); @Override double getW(); @Override float getXf(); @Override float getYf(); @Override float getZf(); @Override float getWf(); @Override double[] toArray(final double[] store); void setX(final double x); void setY(final double y); void setZ(final double z); void setW(final double w); Quaternion set(final double x, final double y, final double z, final double w); Quaternion set(final ReadOnlyQuaternion source); Quaternion fromEulerAngles(final double[] angles); Quaternion fromEulerAngles(final double heading, final double attitude, final double bank); @Override double[] toEulerAngles(final double[] store); Quaternion fromRotationMatrix(final ReadOnlyMatrix3 matrix); Quaternion fromRotationMatrix(final double m00, final double m01, final double m02, final double m10,
      final double m11, final double m12, final double m20, final double m21, final double m22); @Override Matrix3 toRotationMatrix(final Matrix3 store); @Override Matrix4 toRotationMatrix(final Matrix4 store); @Override Vector3 getRotationColumn(final int index, final Vector3 store); Quaternion fromAngleAxis(final double angle, final ReadOnlyVector3 axis); Quaternion fromAngleNormalAxis(final double angle, final ReadOnlyVector3 axis); @Override double toAngleAxis(final Vector3 axisStore); Quaternion fromVectorToVector(final ReadOnlyVector3 from, final ReadOnlyVector3 to); @Override Quaternion normalize(final Quaternion store); Quaternion normalizeLocal(); Quaternion invert(Quaternion store); Quaternion invertLocal(); @Override Quaternion conjugate(Quaternion store); Quaternion conjugateLocal(); @Override Quaternion add(final ReadOnlyQuaternion quat, final Quaternion store); Quaternion addLocal(final ReadOnlyQuaternion quat); @Override Quaternion subtract(final ReadOnlyQuaternion quat, final Quaternion store); Quaternion subtractLocal(final ReadOnlyQuaternion quat); @Override Quaternion multiply(final double scalar, final Quaternion store); Quaternion multiplyLocal(final double scalar); @Override Quaternion multiply(final ReadOnlyQuaternion quat, Quaternion store); Quaternion multiplyLocal(final ReadOnlyQuaternion quat); Quaternion multiplyLocal(final ReadOnlyMatrix3 matrix); Quaternion multiplyLocal(final double qx, final double qy, final double qz, final double qw); Quaternion applyRotation(final double angle, final double x, final double y, final double z); Quaternion applyRotationX(final double angle); Quaternion applyRotationY(final double angle); Quaternion applyRotationZ(final double angle); @Override Vector3 apply(final ReadOnlyVector3 vec, Vector3 store); Quaternion fromAxes(final ReadOnlyVector3 xAxis, final ReadOnlyVector3 yAxis, final ReadOnlyVector3 zAxis); @Override Vector3[] toAxes(final Vector3[] axes); @Override Quaternion slerp(final ReadOnlyQuaternion endQuat, final double changeAmnt, final Quaternion store); Quaternion slerpLocal(final ReadOnlyQuaternion endQuat, final double changeAmnt); static Quaternion slerp(final ReadOnlyQuaternion startQuat, final ReadOnlyQuaternion endQuat,
      final double changeAmnt, final Quaternion store); Quaternion slerpLocal(final ReadOnlyQuaternion startQuat, final ReadOnlyQuaternion endQuat,
      final double changeAmnt, final Quaternion workQuat); Quaternion slerpLocal(final ReadOnlyQuaternion startQuat, final ReadOnlyQuaternion endQuat,
      final double changeAmnt); Quaternion lookAt(final ReadOnlyVector3 direction, final ReadOnlyVector3 up); @Override double magnitudeSquared(); @Override double magnitude(); @Override double dot(final double x, final double y, final double z, final double w); @Override double dot(final ReadOnlyQuaternion quat); Quaternion setIdentity(); @Override boolean isIdentity(); static boolean isValid(final ReadOnlyQuaternion quat); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object o); @Override boolean strictEquals(final Object o); @Override Quaternion clone(); @Override Class<? extends Quaternion> getClassTag(); @Override void write(final OutputCapsule capsule); @Override void read(final InputCapsule capsule); @Override void readExternal(final ObjectInput in); @Override void writeExternal(final ObjectOutput out); final static Quaternion fetchTempInstance(); final static void releaseTempInstance(final Quaternion mat); static final double ALLOWED_DEVIANCE; final static ReadOnlyQuaternion IDENTITY; }
@Test public void testMultiply() { final Quaternion quat1 = new Quaternion(0.5, 1, 2, 3); final Quaternion quat2 = new Quaternion(); assertEquals(new Quaternion(1, 2, 4, 6), quat1.multiply(2, null)); assertEquals(new Quaternion(2, 4, 8, 12), quat1.multiply(4, quat2)); assertEquals(new Quaternion(1, 2, 4, 6), quat1.multiplyLocal(2)); quat1.fromAngleNormalAxis(MathUtils.QUARTER_PI, Vector3.UNIT_Y); quat1.multiply(quat1, quat2); final ReadOnlyVector3 vec = Vector3.UNIT_Z; assertTrue(Math.abs(Vector3.UNIT_X.distance(quat2.apply(vec, null))) <= Quaternion.ALLOWED_DEVIANCE); quat1.multiplyLocal(quat1.getX(), quat1.getY(), quat1.getZ(), quat1.getW()); assertTrue(Math.abs(Vector3.UNIT_X.distance(quat1.apply(vec, null))) <= Quaternion.ALLOWED_DEVIANCE); quat2.fromAngleNormalAxis(MathUtils.HALF_PI, Vector3.UNIT_Y); quat1.multiplyLocal(quat2); assertTrue(Math.abs(Vector3.NEG_UNIT_Z.distance(quat1.apply(vec, null))) <= Quaternion.ALLOWED_DEVIANCE); quat1.multiplyLocal(new Matrix3().applyRotationY(MathUtils.HALF_PI)); assertTrue(Math.abs(Vector3.NEG_UNIT_X.distance(quat1.apply(vec, null))) <= Quaternion.ALLOWED_DEVIANCE); }