@Test public void mult_2d_3d() { Vector3D_F64 a3 = new Vector3D_F64(-1, 2, 1); DenseMatrix64F M = new DenseMatrix64F(3, 3, true, 1, 2, 3, 4, 5, 6, 7, 8, 9); Vector3D_F64 expected = new Vector3D_F64(); GeometryMath_F64.mult(M, a3, expected); Vector2D_F64 a2 = new Vector2D_F64(-1, 2); Vector3D_F64 found = new Vector3D_F64(); GeometryMath_F64.mult(M, a2, found); assertEquals(expected.x, found.x, GrlConstants.DOUBLE_TEST_TOL); assertEquals(expected.y, found.y, GrlConstants.DOUBLE_TEST_TOL); assertEquals(expected.z, found.z, GrlConstants.DOUBLE_TEST_TOL); }
@Test public void mult_3d_2d() { Vector3D_F64 a = new Vector3D_F64(-1, 2, 3); DenseMatrix64F M = new DenseMatrix64F(3, 3, true, 1, 2, 3, 4, 5, 6, 7, 8, 9); Vector2D_F64 c = new Vector2D_F64(); GeometryMath_F64.mult(M, a, c); assertEquals(12.0 / 36.0, c.getX(), GrlConstants.DOUBLE_TEST_TOL); assertEquals(24.0 / 36.0, c.getY(), GrlConstants.DOUBLE_TEST_TOL); }
/** Sees if crossMatrix produces a valid output */ @Test public void crossMatrix_validOut() { double a = 1.1, b = -0.5, c = 2.2; Vector3D_F64 v = new Vector3D_F64(a, b, c); Vector3D_F64 x = new Vector3D_F64(7.6, 2.9, 0.5); Vector3D_F64 found0 = new Vector3D_F64(); Vector3D_F64 found1 = new Vector3D_F64(); GeometryMath_F64.cross(v, x, found0); DenseMatrix64F V = GeometryMath_F64.crossMatrix(a, b, c, null); GeometryMath_F64.mult(V, x, found1); assertEquals(found0.x, found1.x, GrlConstants.DOUBLE_TEST_TOL); assertEquals(found0.y, found1.y, GrlConstants.DOUBLE_TEST_TOL); assertEquals(found0.z, found1.z, GrlConstants.DOUBLE_TEST_TOL); }