T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.set(original); actual.applyTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon()); T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.set(original); actual.applyTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon()); T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.set(original); actual.applyTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon());
@Test public void testDistanceSquared() { Random random = new Random(654135L); for (int i = 0; i < ITERATIONS; i++) { Vector3D translation = EuclidCoreRandomTools.nextVector3DWithFixedLength(random, 1.0); double expectedDistanceSquared = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(Math.sqrt(expectedDistanceSquared)); T p1 = createRandomTuple(random); T p2 = createTuple(p1.getX() + translation.getX(), p1.getY() + translation.getY(), p1.getZ() + translation.getZ()); double actualDistanceSquared = p1.distanceSquared(p2); assertEquals(expectedDistanceSquared, actualDistanceSquared, getEpsilon()); } }
@Test public void testDistanceFromOriginSquared() throws Exception { Random random = new Random(654135L); for (int i = 0; i < ITERATIONS; i++) { Vector3D translation = EuclidCoreRandomTools.nextVector3DWithFixedLength(random, 1.0); double expectedDistanceSquared = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(Math.sqrt(expectedDistanceSquared)); T p = createTuple(translation.getX(), translation.getY(), translation.getZ()); double actualDistance = p.distanceFromOriginSquared(); assertEquals(expectedDistanceSquared, actualDistance, getEpsilon()); } }
@Override @Test public void testGeometricallyEquals() throws Exception { super.testGeometricallyEquals(); Point3D32 pointA; Point3D32 pointB; Random random = new Random(621541L); for (int i = 0; i < 100; ++i) { pointA = EuclidCoreRandomTools.nextPoint3D32(random); pointB = EuclidCoreRandomTools.nextPoint3D32(random); if (((Point3DReadOnly) pointA).geometricallyEquals(pointB, getEpsilon())) { assertTrue(pointA.geometricallyEquals(pointB, getEpsilon())); } else { assertFalse(pointA.geometricallyEquals(pointB, getEpsilon())); } } }
@Override public void testSetters() throws Exception { super.testSetters(); Random random = new Random(621541L); Point3D32 tuple1 = createEmptyTuple(); for (int i = 0; i < ITERATIONS; i++) { // Test setX(float x) float x = random.nextFloat(); tuple1.setX(x); assertEquals(tuple1.getX32(), x, getEpsilon()); } for (int i = 0; i < ITERATIONS; i++) { // Test setY(float y) float y = random.nextFloat(); tuple1.setY(y); assertEquals(tuple1.getY32(), y, getEpsilon()); } for (int i = 0; i < ITERATIONS; i++) { // Test setZ(float z) float z = random.nextFloat(); tuple1.setZ(z); assertEquals(tuple1.getZ32(), z, getEpsilon()); } }
pointB = EuclidCoreRandomTools.nextPoint3D(random); if (pointA.epsilonEquals(pointB, getEpsilon())) assertTrue(pointA.geometricallyEquals(pointB, Math.sqrt(3) * getEpsilon())); + (pointA.getZ() - pointB.getZ()) * (pointA.getZ() - pointB.getZ())) <= getEpsilon()) assertTrue(pointA.geometricallyEquals(pointB, getEpsilon())); assertFalse(pointA.geometricallyEquals(pointB, getEpsilon()));
@Test public void testDistanceFromOrigin() throws Exception { Random random = new Random(654135L); for (int i = 0; i < ITERATIONS; i++) { Vector3D translation = EuclidCoreRandomTools.nextVector3DWithFixedLength(random, 1.0); double expectedDistance = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(expectedDistance); T p = createTuple(translation.getX(), translation.getY(), translation.getZ()); double actualDistance = p.distanceFromOrigin(); assertEquals(expectedDistance, actualDistance, getEpsilon()); } }
@Override @Test public void testGeometricallyEquals() throws Exception { super.testGeometricallyEquals(); Point3D pointA; Point3D pointB; Random random = new Random(621541L); for (int i = 0; i < 100; ++i) { pointA = EuclidCoreRandomTools.nextPoint3D(random); pointB = EuclidCoreRandomTools.nextPoint3D(random); if (((Point3DReadOnly) pointA).geometricallyEquals(pointB, getEpsilon())) { assertTrue(pointA.geometricallyEquals(pointB, getEpsilon())); } else { assertFalse(pointA.geometricallyEquals(pointB, getEpsilon())); } } }
@Test public void testDistance() { Random random = new Random(654135L); for (int i = 0; i < ITERATIONS; i++) { Vector3D translation = EuclidCoreRandomTools.nextVector3DWithFixedLength(random, 1.0); double expectedDistance = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(expectedDistance); T p1 = createRandomTuple(random); T p2 = createTuple(p1.getX() + translation.getX(), p1.getY() + translation.getY(), p1.getZ() + translation.getZ()); double actualDistance = p1.distance(p2); assertEquals(expectedDistance, actualDistance, getEpsilon()); } }
T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.applyTransform(transform); actual.applyInverseTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon()); T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.applyTransform(transform); actual.applyInverseTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon()); EuclidCoreRandomTools.nextPoint3D(random, 10.0)); T original = createRandomTuple(random); T expected = createEmptyTuple(); T actual = createEmptyTuple(); actual.applyTransform(transform); actual.applyInverseTransform(transform); EuclidCoreTestTools.assertTuple3DEquals(expected, actual, getEpsilon());
@Test public void testDistanceXYSquared() { Random random = new Random(65415L); for (int i = 0; i < ITERATIONS; i++) { // With other point 3D Vector3D translation = EuclidCoreRandomTools.nextVector3D(random, 1.0, 2.0); translation.setZ(0.0); translation.normalize(); double expectedDistanceSquared = EuclidCoreRandomTools.nextDouble(random, 1.0, 10.0); translation.scale(Math.sqrt(expectedDistanceSquared)); T p1 = createRandomTuple(random); T p2 = createTuple(p1.getX() + translation.getX(), p1.getY() + translation.getY(), p1.getZ() + random.nextDouble()); double actualDistance = p1.distanceXYSquared(p2); assertEquals(expectedDistanceSquared, actualDistance, 10.0 * getEpsilon()); } for (int i = 0; i < ITERATIONS; i++) { // With point 2D Vector3D translation = EuclidCoreRandomTools.nextVector3D(random, 1.0, 2.0); translation.setZ(0.0); translation.normalize(); double expectedDistanceSquared = EuclidCoreRandomTools.nextDouble(random, 1.0, 10.0); translation.scale(Math.sqrt(expectedDistanceSquared)); T p1 = createRandomTuple(random); Point2D p2 = new Point2D(p1.getX() + translation.getX(), p1.getY() + translation.getY()); double actualDistance = p1.distanceXYSquared(p2); assertEquals(expectedDistanceSquared, actualDistance, getEpsilon()); } }
@Test public void testDistanceXY() { Random random = new Random(654135L); for (int i = 0; i < ITERATIONS; i++) { // With other point 3D Vector3D translation = EuclidCoreRandomTools.nextVector3D(random); translation.setZ(0.0); translation.normalize(); double expectedDistance = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(expectedDistance); T p1 = createRandomTuple(random); T p2 = createTuple(p1.getX() + translation.getX(), p1.getY() + translation.getY(), p1.getZ() + random.nextDouble()); double actualDistance = p1.distanceXY(p2); assertEquals(expectedDistance, actualDistance, getEpsilon()); } for (int i = 0; i < ITERATIONS; i++) { // With point 2D Vector3D translation = EuclidCoreRandomTools.nextVector3D(random); translation.setZ(0.0); translation.normalize(); double expectedDistance = EuclidCoreRandomTools.nextDouble(random, 0.0, 10.0); translation.scale(expectedDistance); T p1 = createRandomTuple(random); Point2D p2 = new Point2D(p1.getX() + translation.getX(), p1.getY() + translation.getY()); double actualDistance = p1.distanceXY(p2); assertEquals(expectedDistance, actualDistance, getEpsilon()); } }