public void testQueryPolygon() throws Exception { System.out.println("Testing queryPolygon()"); Pointing[] corner = new Pointing[4]; corner[0] = new Pointing(new Vec3(1, 0.01, 0.01)); corner[1] = new Pointing(new Vec3(1, 1, -0.3)); corner[2] = new Pointing(new Vec3(0.01, 1, 0.01)); corner[3] = new Pointing(new Vec3(0.01, 0.01, 1)); RangeSet lrs = HealpixProc.queryPolygonNest(10, corner); assertEquals("QueryPolygon problem", lrs.nval(), 1696714); lrs = HealpixProc.queryPolygonInclusiveNest(10, corner, 4); assertEquals("QueryPolygon problem", lrs.nval(), 1700206); lrs = HealpixProc.queryPolygonRing(10, corner); assertEquals("QueryPolygon problem", lrs.nval(), 1696714); lrs = HealpixProc.queryPolygonInclusiveRing(10, corner, 4); assertEquals("QueryPolygon problem", lrs.nval(), 1700206); }
public void testQueryPolygon2() throws Exception { System.out.println("Testing queryPolygon() empirically"); int omax = 17; Random rng = new Random(5); for (int o = 0; o <= omax; ++o) { int niter = Math.max(1, Math.min(nsamples / 1000, 100000 >> o)); for (int m = 0; m < niter; ++m) { Pointing[] corner = new Pointing[3]; corner[0] = random_dir(rng); corner[1] = random_dir(rng); corner[2] = random_dir(rng); RangeSet rs = HealpixProc.queryPolygonRing(o, corner); long nval = rs.nval(); rs = HealpixProc.queryPolygonNest(o, corner); assertEquals("queryPolygon problem 1", nval, rs.nval()); rs = HealpixProc.queryPolygonInclusiveRing(o, corner, 4); long nv1 = rs.nval(); rs = HealpixProc.queryPolygonInclusiveNest(o, corner, 4); long nv2 = rs.nval(); assertTrue("queryPolygon problem 2", nv1 >= nv2); assertTrue("queryPolygon problem 3", nv2 >= nval); } } }