Tetrahedral2DParity extends GeometricParity { @Override public int parity() { double x1 = coordinates[0].x; double x2 = coordinates[1].x; double x3 = coordinates[2].x; double x4 = coordinates[3].x; double y1 = coordinates[0].y; double y2 = coordinates[1].y; double y3 = coordinates[2].y; double y4 = coordinates[3].y; double det = (elevations[0] * det(x2, y2, x3, y3, x4, y4)) - (elevations[1] * det(x1, y1, x3, y3, x4, y4)) + (elevations[2] * det(x1, y1, x2, y2, x4, y4)) - (elevations[3] * det(x1, y1, x2, y2, x3, y3)); return (int) Math.signum(det); } Tetrahedral2DParity(Point2d[] coordinates, int[] elevations); @Override int parity();  }
@Test public void testParity_Four_NNND() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{0, 0, 0, -1}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(CLOCKWISE)); }
@Test public void testParity_Four_NNNU() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{0, 0, 0, 1}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(ANTICLOCKWISE)); }
@Test public void testParity_Four_NNNN() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{0, 0, 0, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(NONE)); }
@Test public void testParity_Four_UUUN() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{1, 1, 1, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(CLOCKWISE)); }
@Test public void testParity_Four_DDDN() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{-1, -1, -1, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(ANTICLOCKWISE)); }
@Test public void testParity_Four_UUUU() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{1, 1, 1, 1}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(NONE)); }
@Test public void testParity_Four_DDDD() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-9.09, 5.02), }; int[] elev = new int[]{-1, -1, -1, -1}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(NONE)); }
@Test public void testParity_Three_UNN() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-7.75, 4.25), }; int[] elev = new int[]{1, 0, 0, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(CLOCKWISE)); }
@Test public void testParity_Three_UUU() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-7.75, 4.25), }; int[] elev = new int[]{1, 1, 1, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(CLOCKWISE)); }
@Test public void testParity_Three_DNN() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-7.75, 4.25), }; int[] elev = new int[]{-1, 0, 0, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(ANTICLOCKWISE)); }
@Test public void testParity_Three_DDD() { Point2d[] coords = new Point2d[]{new Point2d(-7.75, 5.79), new Point2d(-6.42, 3.48), new Point2d(-9.09, 3.48), new Point2d(-7.75, 4.25), }; int[] elev = new int[]{-1, -1, -1, 0}; GeometricParity parity = new Tetrahedral2DParity(coords, elev); org.hamcrest.MatcherAssert.assertThat(parity.parity(), is(ANTICLOCKWISE)); }