Example #1
0
 def test_unproject(self):
     camera = Camera()
     pixel_pos = (960, 720)
     sph = camera.unproject(pixel_pos)
     self.assertEquals(sph[0], np.pi)
     self.assertEquals(sph[1], np.pi / 2)
     pixel_pos = (960, 0)
     sph = camera.unproject(pixel_pos)
     self.assertEquals(sph[0], 3 * np.pi / 2)
     self.assertEquals(sph[1], np.pi / 2 - np.deg2rad(5))
     pixel_pos = (960, 1440)
     sph = camera.unproject(pixel_pos)
     self.assertEquals(sph[0], np.pi / 2)
     self.assertEquals(sph[1], np.pi / 2 - np.deg2rad(5))
     pixel_pos = (1920, 720)
     sph = camera.unproject(pixel_pos)
     self.assertEquals(sph[0], np.pi)
     self.assertEquals(sph[1], np.pi / 2 - np.deg2rad(5))
     pixel_pos = (0, 720)
     sph = camera.unproject(pixel_pos)
     self.assertEquals(sph[0], 0)
     self.assertEquals(sph[1], np.pi / 2 - np.deg2rad(5))
     pixel_pos = (0, 0)
     pixel_pos2 = (1920, 1440)
     sph = camera.unproject(pixel_pos)
     sph2 = camera.unproject(pixel_pos2)
     star1 = Star(0, 0, sph=sph)
     star2 = Star(1, 0, sph=sph2)
     d = star1.calc_angular_distance(star2)
     actual = 2 * np.arctan(np.tan(np.deg2rad(5)) * np.sqrt(2))
     self.assertEquals(round(d, 5), round(actual, 5))
 def test_calc_angular_distance_180(self):
     star1 = Star(1, 0, sph=(315 * self.d2r, 45 * self.d2r))
     star2 = Star(2, 0, sph=(135 * self.d2r, -45 * self.d2r))
     angle = round(star1.calc_angular_distance(star2), 5)
     check = round(np.pi, 5)
     self.assertEquals(angle, check)
 def test_calc_angular_distance_0(self):
     star1 = Star(1, 0, sph=(40, 11))
     star2 = Star(2, 0, sph=(40, 11))
     self.assertEquals(star1.calc_angular_distance(star2), 0)
 def test_calc_angular_distance_1d(self):
     star1 = Star(1, 0, sph=(40 * self.d2r, 0))
     star2 = Star(2, 0, sph=(50 * self.d2r, 0))
     angle = round(star1.calc_angular_distance(star2), 5)
     check = round(10 * self.d2r, 5)
     self.assertEquals(angle, check)