@Override public Vector4D32 createTuple(double x, double y, double z, double s) { return new Vector4D32((float) x, (float) y, (float) z, (float) s); }
Vector4D32 vector = new Vector4D32(); assertTrue(vector.getX32() == 0.0f); assertTrue(vector.getY32() == 0.0f); assertTrue(vector.getZ32() == 0.0f); assertTrue(vector.getS32() == 0.0f); float z = random.nextFloat(); float s = random.nextFloat(); Vector4D32 vector = new Vector4D32(x, y, z, s); assertTrue(vector.getX32() == x); assertTrue(vector.getY32() == y); assertTrue(vector.getZ32() == z); assertTrue(vector.getS32() == s); float s = random.nextFloat(); float[] vectorArray = {x, y, z, s}; Vector4D32 vector = new Vector4D32(vectorArray); assertTrue(vector.getX32() == x); assertTrue(vector.getY32() == y); assertTrue(vector.getZ32() == z); assertTrue(vector.getS32() == s); Vector4D32 vector = new Vector4D32(quaternion); EuclidCoreTestTools.assertTuple4DEquals(quaternion, vector, EPS); Vector4D32 vector = new Vector4D32(quaternion); EuclidCoreTestTools.assertTuple4DEquals(quaternion, vector, EPS); Vector4D32 vector = new Vector4D32(vector3D);
public static Vector4D32 nextVector4D32(Random random, Tuple4DReadOnly lowerBound, Tuple4DReadOnly upperBound) { Vector4D32 ret = new Vector4D32(); ret.setX(RandomNumbers.nextFloat(random, lowerBound.getX32(), upperBound.getX32())); ret.setY(RandomNumbers.nextFloat(random, lowerBound.getY32(), upperBound.getY32())); ret.setZ(RandomNumbers.nextFloat(random, lowerBound.getZ32(), upperBound.getZ32())); ret.setS(RandomNumbers.nextFloat(random, lowerBound.getS32(), upperBound.getS32())); return ret; }
@Test public void testHashCode() throws Exception { Random random = new Random(621541L); Vector4D32 vector = createRandomTuple(random); int newHashCode, previousHashCode; newHashCode = vector.hashCode(); assertEquals(newHashCode, vector.hashCode()); previousHashCode = vector.hashCode(); for (int i = 0; i < ITERATIONS; i++) { vector.setElement(i % 4, random.nextDouble()); newHashCode = vector.hashCode(); assertNotEquals(newHashCode, previousHashCode); previousHashCode = newHashCode; } }
@Override @Test public void testGeometricallyEquals() throws Exception { super.testGeometricallyEquals(); Vector4D32 vectorA; Vector4D32 vectorB; Random random = new Random(621541L); for (int i = 0; i < 100; ++i) { vectorA = EuclidCoreRandomTools.nextVector4D32(random); vectorB = EuclidCoreRandomTools.nextVector4D32(random); if (((Vector4DReadOnly) vectorA).geometricallyEquals(vectorB, getEpsilon())) { assertTrue(vectorA.geometricallyEquals(vectorB, getEpsilon())); } else { assertFalse(vectorA.geometricallyEquals(vectorB, getEpsilon())); } } }
@Override public Vector4D32 createEmptyTuple() { return new Vector4D32(); }