示例#1
0
文件: observer.py 项目: ana-max/sky
 def __init__(self, longitude, latitude, angle, vector, time_now):
     self.input_longitude = longitude
     self.input_latitude = latitude
     self.input_angle = angle
     self.input_vector = vector
     vector = vector[1:-1].split(',')
     self.vector = Cartesian(vector[0], vector[1], vector[2])
     longitude = self.conversion_to_degrees(longitude)
     latitude = self.conversion_to_degrees(latitude)
     self.is_eastern_longitude = longitude > 0
     self.is_northern_latitude = latitude > 0
     self.longitude = longitude if longitude > 0 else -longitude
     self.latitude = latitude if latitude > 0 else -latitude
     self.horizontal = Horizontal(self.longitude, self.latitude)
     self.angle = self.conversion_to_degrees(angle)
     self.time_zone = longitude//15
     is_datetime = type(time_now) == datetime.datetime
     if not is_datetime:
         self.input_time_now = time_now
     else:
         self.input_time_now = str(time_now.hour) + ':' + \
                               str(time_now.minute) + ':' + \
                               str(time_now.second)
     self.time_now = time_now if is_datetime else \
         self._conversion_to_datetime(time_now)
示例#2
0
class CartesianTest(unittest.TestCase):
    def setUp(self):
        self.converter = Cartesian(1, 2, 3)
        self.observer = Observer('-64:00:00', '00:00:00', '60:00:00',
                                 '(0,0,0)', '21:30:50')

    def test_convert_to_screen(self):
        screen = self.converter.cartesian_to_screen(self.observer)
        self.assertEqual(screen.x, 0.5773502691896258)
        self.assertEqual(screen.y, 1.1547005383792517)

    def test_to_string(self):
        screen = Cartesian(1, 1, 1).cartesian_to_screen(self.observer)
        self.assertEqual(str(screen),
                         '(1.7320508075688776,1.7320508075688776)')
示例#3
0
 def test_to_string(self):
     screen = Cartesian(1, 1, 1).cartesian_to_screen(self.observer)
     self.assertEqual(str(screen),
                      '(1.7320508075688776,1.7320508075688776)')
示例#4
0
 def setUp(self):
     self.converter = Cartesian(1, 2, 3)
     self.observer = Observer('-64:00:00', '00:00:00', '60:00:00',
                              '(0,0,0)', '21:30:50')
示例#5
0
 def test_rotate_z(self):
     point3d = self.camera.rotate_z(Cartesian(30, 30, 30))
     self.assertEqual(point3d[0], 10.980762113533162)
     self.assertEqual(point3d[1], 40.98076211353316)
     self.assertEqual(point3d[2], 30.0)
示例#6
0
 def test_rotate_y(self):
     point3d = self.camera.rotate_y(Cartesian(30, 30, 30))
     self.assertEqual(point3d[0], 30.000000000000004)
     self.assertEqual(point3d[1], 30.0)
     self.assertEqual(point3d[2], -29.999999999999996)