/** * Converts this quaternion to a rotation matrix and then extracts rotation axes. * * @param axes * the array of vectors to be filled. * @throws ArrayIndexOutOfBoundsException * if the given axes array is smaller than 3 elements. * @return the axes */ @Override public Vector3[] toAxes(final Vector3[] axes) { final Matrix3 tempMat = toRotationMatrix(Matrix3.fetchTempInstance()); axes[2] = tempMat.getColumn(2, axes[2]); axes[1] = tempMat.getColumn(1, axes[1]); axes[0] = tempMat.getColumn(0, axes[0]); Matrix3.releaseTempInstance(tempMat); return axes; }
/** * Converts this quaternion to a rotation matrix and then extracts rotation axes. * * @param axes * the array of vectors to be filled. * @throws ArrayIndexOutOfBoundsException * if the given axes array is smaller than 3 elements. * @return the axes */ @Override public Vector3[] toAxes(final Vector3[] axes) { final Matrix3 tempMat = toRotationMatrix(Matrix3.fetchTempInstance()); axes[2] = tempMat.getColumn(2, axes[2]); axes[1] = tempMat.getColumn(1, axes[1]); axes[0] = tempMat.getColumn(0, axes[0]); Matrix3.releaseTempInstance(tempMat); return axes; }
final Matrix3 mat = quat.toRotationMatrix((Matrix3) null); assertTrue(Math.abs(quat.apply(Vector3.NEG_ONE, null).distance(mat.applyPost(Vector3.NEG_ONE, null))) <= MathUtils.EPSILON); quat.toRotationMatrix(mat); assertTrue(Math.abs(quat.apply(Vector3.ONE, null).distance(mat.applyPost(Vector3.ONE, null))) <= MathUtils.EPSILON); assertEquals(Matrix3.IDENTITY, quat.toRotationMatrix((Matrix3) null)); final Matrix4 mat4 = quat.toRotationMatrix((Matrix4) null); assertTrue(Math.abs(quat.apply(Vector3.NEG_ONE, null).distance(mat4.applyPostVector(Vector3.NEG_ONE, null))) <= MathUtils.EPSILON); quat.toRotationMatrix(mat4); assertTrue(Math.abs(quat.apply(Vector3.ONE, null).distance(mat4.applyPostVector(Vector3.ONE, null))) <= MathUtils.EPSILON); assertEquals(Matrix4.IDENTITY, quat.toRotationMatrix((Matrix4) null));
_rotateStore.multiplyLocal(new Quaternion().fromVectorToVector(_calcVec3A, _calcVec3B).toRotationMatrix( _calcMat3));
kQ.normalizeLocal(); final Matrix3 kBoxaxis = kQ.toRotationMatrix(Matrix3.fetchTempInstance()); final Vector3 newXaxis = kBoxaxis.getColumn(0, Vector3.fetchTempInstance()); final Vector3 newYaxis = kBoxaxis.getColumn(1, Vector3.fetchTempInstance());
kQ.normalizeLocal(); final Matrix3 kBoxaxis = kQ.toRotationMatrix(Matrix3.fetchTempInstance()); final Vector3 newXaxis = kBoxaxis.getColumn(0, Vector3.fetchTempInstance()); final Vector3 newYaxis = kBoxaxis.getColumn(1, Vector3.fetchTempInstance());