/** * Sets the values of this matrix to the values of the provided double array. * * @param source * @return this matrix for chaining * @throws NullPointerException * if source is null. * @throws ArrayIndexOutOfBoundsException * if source array has a length less than 9. */ public Matrix3 fromArray(final double[] source) { return fromArray(source, true); }
/** * Sets the values of this matrix to the values of the provided double array. * * @param source * @return this matrix for chaining * @throws NullPointerException * if source is null. * @throws ArrayIndexOutOfBoundsException * if source array has a length less than 9. */ public Matrix3 fromArray(final double[] source) { return fromArray(source, true); }
@Test public void testToArray() { final double[] values = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final Matrix3 mat3A = new Matrix3().fromArray(values); // row major final double[] dbls1 = mat3A.toArray(null); for (int i = 0; i < 9; i++) { assertTrue(values[i] == dbls1[i]); } // column major final double[] colmajor = { 0, 3, 6, 1, 4, 7, 2, 5, 8 }; mat3A.toArray(dbls1, false); for (int i = 0; i < 9; i++) { assertTrue(colmajor[i] == dbls1[i]); } }
final double[] colmajor = { 0, 3, 6, 1, 4, 7, 2, 5, 8 }; final Matrix3 mat3A = new Matrix3().fromArray(values);
_matData[8] = upDotEmit + f7 * _upXemit.getZ(); _rotMatrix.fromArray(_matData); _oldEmit.set(_worldEmit);
@Test public void testFromArray() { final double[] values = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final Matrix3 mat3A = new Matrix3(); // row major mat3A.fromArray(values); assertTrue(0 == mat3A.getM00()); assertTrue(1 == mat3A.getM01()); assertTrue(2 == mat3A.getM02()); assertTrue(3 == mat3A.getM10()); assertTrue(4 == mat3A.getM11()); assertTrue(5 == mat3A.getM12()); assertTrue(6 == mat3A.getM20()); assertTrue(7 == mat3A.getM21()); assertTrue(8 == mat3A.getM22()); // column major mat3A.setIdentity(); mat3A.fromArray(values, false); assertTrue(0 == mat3A.getM00()); assertTrue(3 == mat3A.getM01()); assertTrue(6 == mat3A.getM02()); assertTrue(1 == mat3A.getM10()); assertTrue(4 == mat3A.getM11()); assertTrue(7 == mat3A.getM12()); assertTrue(2 == mat3A.getM20()); assertTrue(5 == mat3A.getM21()); assertTrue(8 == mat3A.getM22()); }
_matData[8] = upDotEmit + f7 * _upXemit.getZ(); _rotMatrix.fromArray(_matData); _oldEmit.set(_worldEmit);