/** * An instance which is easily visualized for understanding the forwards intersection instance. * * @throws Exception */ @Test public void testSimpleIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(0.8, 0.8, 0.0), new Vec3(0.0, -1.0, 0.0)); boolean intersection = wgs84.intersect(mockedGlobe, ray, new Vec3()); assertTrue("simple intersection", intersection); }
/** * An instance which is easily visualized for understanding the backwards intersection instance. * * @throws Exception */ @Test public void testSimpleBackwardsIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(0.8, 0.8, 0.0), new Vec3(0.0, 1.0, 0.0)); boolean intersection = wgs84.intersect(mockedGlobe, ray, new Vec3()); assertFalse("simple backwards intersection", intersection); }
/** * An instance which demonstrates two intersections with a ray originating within the ellipsoid. * * @throws Exception */ @Test public void testSimpleTwoIntersectionInternal() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(-0.8, 0, 0.0), new Vec3(1.0, 0.0, 0.0).normalize()); Vec3 result = new Vec3(); double errorThreshold = 1e-9; boolean intersection = wgs84.intersect(mockedGlobe, ray, result); assertTrue("simple internal intersection", intersection); assertEquals("forward calculated intersection x", 1.0, result.x, errorThreshold); assertEquals("forward calculated intersection y", 0.0, result.y, errorThreshold); }
/** * An instance which demonstrates two intersections, but the closest, or first surface intersection position is * desired. * * @throws Exception */ @Test public void testSimpleTwoIntersection() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Globe mockedGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(mockedGlobe.getEquatorialRadius()).thenReturn(1.0); PowerMockito.when(mockedGlobe.getPolarRadius()).thenReturn(1.0); Line ray = new Line(new Vec3(-1.0, 2.0, 0.0), new Vec3(1.0, -1.0, 0.0).normalize()); Vec3 result = new Vec3(); double errorThreshold = 1e-9; boolean intersection = wgs84.intersect(mockedGlobe, ray, result); assertTrue("simple intersection", intersection); assertEquals("nearest calculated intersection x", 0.0, result.x, errorThreshold); assertEquals("nearest calculated intersection y", 1.0, result.y, errorThreshold); }
/** * This test case was provided by the COE EMP team. Visually, it is obvious the Line in this examples has a * direction and origin that will not intersect the ellipsoid. * * @throws Exception */ @Test public void testEmpBackwardInstance() throws Exception { ProjectionWgs84 wgs84 = new ProjectionWgs84(); Line ray = new Line(new Vec3(990474.8037403631, 3007310.9566306924, 5583923.602748461), new Vec3(-0.1741204769506282, 0.9711294099374702, -0.16306357245254538)); boolean intersection = wgs84.intersect(this.globe, ray, new Vec3()); assertFalse("EMP backward intersection", intersection); }