@Test public void cross_2d_3d() { Vector2D_F64 aa = new Vector2D_F64(0.75, 2); Vector3D_F64 a = new Vector3D_F64(0.75, 2, 1); Vector3D_F64 b = new Vector3D_F64(3, 0.1, 4); Vector3D_F64 expected = new Vector3D_F64(); Vector3D_F64 found = new Vector3D_F64(); GeometryMath_F64.cross(a, b, expected); GeometryMath_F64.cross(aa, b, 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 cross_3d_3d() { Vector3D_F64 a = new Vector3D_F64(1, 0, 0); Vector3D_F64 b = new Vector3D_F64(0, 1, 0); Vector3D_F64 c = new Vector3D_F64(); GeometryMath_F64.cross(a, b, c); assertEquals(0, c.x, GrlConstants.DOUBLE_TEST_TOL); assertEquals(0, c.y, GrlConstants.DOUBLE_TEST_TOL); assertEquals(1, c.z, GrlConstants.DOUBLE_TEST_TOL); GeometryMath_F64.cross(b, a, c); assertEquals(0, c.x, GrlConstants.DOUBLE_TEST_TOL); assertEquals(0, c.y, GrlConstants.DOUBLE_TEST_TOL); assertEquals(-1, c.z, 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); }