Tetrahedral3DParity 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 z1 = coordinates[0].z; double z2 = coordinates[1].z; double z3 = coordinates[2].z; double z4 = coordinates[3].z; double det = (z1 * det(x2, y2, x3, y3, x4, y4)) - (z2 * det(x1, y1, x3, y3, x4, y4)) + (z3 * det(x1, y1, x2, y2, x4, y4)) - (z4 * det(x1, y1, x2, y2, x3, y3)); return (int) Math.signum(det); } Tetrahedral3DParity(Point3d[] coordinates); @Override int parity();  }
@Test public void testParity_Three_Clockwise() { Point3d[] coords = new Point3d[]{new Point3d(1.70, 0.98, -0.51), new Point3d(2.65, -0.83, 0.62), new Point3d(0.26, -0.33, 0.95), new Point3d(1.44, -0.33, -0.03), }; assertThat(new Tetrahedral3DParity(coords).parity(), is(CLOCKWISE)); }
@Test public void testParity_Three_Anticlockwise() { Point3d[] coords = new Point3d[]{new Point3d(1.70, 0.98, -0.51), new Point3d(0.26, -0.33, 0.95), new Point3d(2.65, -0.83, 0.62), new Point3d(1.44, -0.33, -0.03), }; assertThat(new Tetrahedral3DParity(coords).parity(), is(ANTICLOCKWISE)); }
@Test public void testParity_Four_Clockwise() { Point3d[] coords = new Point3d[]{new Point3d(1.70, 0.98, -0.51), new Point3d(2.65, -0.83, 0.62), new Point3d(0.26, -0.33, 0.95), new Point3d(1.21, -0.97, -0.89), }; assertThat(new Tetrahedral3DParity(coords).parity(), is(CLOCKWISE)); }
@Test public void testParity_Four_Anticlockwise() { Point3d[] coords = new Point3d[]{new Point3d(1.70, 0.98, -0.51), new Point3d(0.26, -0.33, 0.95), new Point3d(2.65, -0.83, 0.62), new Point3d(1.21, -0.97, -0.89), }; assertThat(new Tetrahedral3DParity(coords).parity(), is(ANTICLOCKWISE)); }