def test_center_and_dimensions(self): b = Box.fromDegrees(-90, -45, 90, 45) self.assertEqual(b.getCenter(), LonLat.fromDegrees(0, 0)) self.assertEqual(b.getWidth(), Angle.fromDegrees(180)) self.assertEqual(b.getHeight(), Angle.fromDegrees(90)) self.assertEqual(b.getLon().getA(), NormalizedAngle.fromDegrees(-90)) self.assertEqual(b.getLat().getB(), Angle.fromDegrees(45))
def testConstruction(self): a1 = Angle(1.0) a2 = Angle.fromRadians(1.0) a3 = Angle.fromDegrees(57.29577951308232) self.assertEqual(a1, a2) self.assertEqual(a1.asRadians(), 1.0) self.assertEqual(a1, a3) self.assertEqual(a1.asDegrees(), 57.29577951308232)
def testConstruction(self): a1 = Angle(1.0) a2 = Angle.fromRadians(1.0) a3 = Angle.fromDegrees(57.29577951308232) self.assertEqual(a1, a2) self.assertEqual(a1.asRadians(), 1.0) self.assertEqual(a1, a3) self.assertEqual(a1.asDegrees(), 57.29577951308232)
def testConstruction(self): v = Vector3d(1, 1, 1) u = UnitVector3d.orthogonalTo(v) self.assertAlmostEqual(u.dot(v), 0.0, places=15) a = UnitVector3d(1, 1, 1) self.assertEqual(a, UnitVector3d(Vector3d(1, 1, 1))) self.assertAlmostEqual(a.x(), math.sqrt(3.0) / 3.0, places=15) self.assertAlmostEqual(a.y(), math.sqrt(3.0) / 3.0, places=15) self.assertAlmostEqual(a.z(), math.sqrt(3.0) / 3.0, places=15) b = UnitVector3d(Angle.fromDegrees(45), Angle.fromDegrees(45)) self.assertEqual(b, UnitVector3d(LonLat.fromDegrees(45, 45))) self.assertAlmostEqual(b.x(), 0.5, places=15) self.assertAlmostEqual(b.y(), 0.5, places=15) self.assertAlmostEqual(b.z(), 0.5 * math.sqrt(2.0), places=15) c = UnitVector3d.northFrom(b) d = UnitVector3d(LonLat.fromDegrees(225, 45)) self.assertAlmostEqual(c.x(), d.x(), places=15) self.assertAlmostEqual(c.y(), d.y(), places=15) self.assertAlmostEqual(c.z(), d.z(), places=15)
def testConstruction(self): p = LonLat.fromDegrees(45, 45) self.assertEqual(p, LonLat(NormalizedAngle.fromDegrees(45), Angle.fromDegrees(45))) u = UnitVector3d(p) q = LonLat(u) self.assertAlmostEqual(p.getLon().asRadians(), q.getLon().asRadians(), places=13) self.assertAlmostEqual(p.getLat().asRadians(), q.getLat().asRadians(), places=13) self.assertAlmostEqual(p.getLon().asRadians(), LonLat.latitudeOf(u).asRadians(), places=13) self.assertAlmostEqual(p.getLon().asRadians(), LonLat.longitudeOf(u).asRadians(), places=13)
def test_envelope_and_interior(self): pixelization = HtmPixelization(3) c = Circle(UnitVector3d(1, 1, 1), Angle.fromDegrees(0.1)) rs = pixelization.envelope(c) self.assertTrue(rs == RangeSet(0x3ff)) rs = pixelization.envelope(c, 1) self.assertTrue(rs == RangeSet(0x3ff)) self.assertTrue(rs.isWithin(pixelization.universe())) rs = pixelization.interior(c) self.assertTrue(rs.empty())
def test_envelope_and_interior(self): pixelization = Mq3cPixelization(1) c = Circle(UnitVector3d(1.0, -0.5, -0.5), Angle.fromDegrees(0.1)) rs = pixelization.envelope(c) self.assertTrue(rs == RangeSet(44)) rs = pixelization.envelope(c, 1) self.assertTrue(rs == RangeSet(44)) self.assertTrue(rs.isWithin(pixelization.universe())) rs = pixelization.interior(c) self.assertTrue(rs.empty())
def testConstruction(self): v = Vector3d(1, 1, 1) u = UnitVector3d.orthogonalTo(v) self.assertAlmostEqual(u.dot(v), 0.0, places=15) u = UnitVector3d(1, 1, 1) self.assertEqual(u, UnitVector3d(Vector3d(1, 1, 1))) self.assertAlmostEqual(u.x(), math.sqrt(3.0) / 3.0, places=15) self.assertAlmostEqual(u.y(), math.sqrt(3.0) / 3.0, places=15) self.assertAlmostEqual(u.z(), math.sqrt(3.0) / 3.0, places=15) u = UnitVector3d(Angle.fromDegrees(45), Angle.fromDegrees(45)) self.assertEqual(u, UnitVector3d(LonLat.fromDegrees(45, 45))) self.assertAlmostEqual(u.x(), 0.5, places=15) self.assertAlmostEqual(u.y(), 0.5, places=15) self.assertAlmostEqual(u.z(), 0.5 * math.sqrt(2.0), places=15) u = UnitVector3d.northFrom(u.asVector3d()) w = UnitVector3d(LonLat.fromDegrees(225, 45)) self.assertAlmostEqual(u.x(), w.x(), places=15) self.assertAlmostEqual(u.y(), w.y(), places=15) self.assertAlmostEqual(u.z(), w.z(), places=15)
def test_relationships(self): c = Circle(UnitVector3d.X(), Angle.fromDegrees(0.1)) d = Circle(UnitVector3d(1, 1, 1), Angle(math.pi / 2)) e = Circle(-UnitVector3d.X()) self.assertTrue(c.contains(UnitVector3d.X())) self.assertTrue(UnitVector3d.X() in c) self.assertTrue(d.contains(c)) self.assertTrue(c.isWithin(d)) self.assertTrue(c.intersects(d)) self.assertTrue(c.intersects(UnitVector3d.X())) self.assertTrue(e.isDisjointFrom(d)) self.assertEqual(d.relate(c), CONTAINS) self.assertEqual(e.relate(d), DISJOINT)
def testConstruction(self): p = LonLat.fromDegrees(45, 45) self.assertEqual(p, LonLat(NormalizedAngle.fromDegrees(45), Angle.fromDegrees(45))) u = UnitVector3d(p) q = LonLat(u) self.assertAlmostEqual( p.getLon().asRadians(), q.getLon().asRadians(), places=13) self.assertAlmostEqual( p.getLat().asRadians(), q.getLat().asRadians(), places=13) self.assertAlmostEqual(p.getLon().asRadians(), LonLat.latitudeOf(u).asRadians(), places=13) self.assertAlmostEqual(p.getLon().asRadians(), LonLat.longitudeOf(u).asRadians(), places=13)