forked from YuhangSong/DHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_view_lib_new.py
executable file
·37 lines (27 loc) · 1.15 KB
/
move_view_lib_new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import math
class view_mover():
def __init__(self):
self.R = 1.0
self.e=0.0818191908426
self.init_position(116.34469,39.9751)
def init_position(self, Longitude, Latitude):
self.Latitude = Latitude*math.pi/180.0
self.Longitude = Longitude*math.pi/180.0
self.constrain_lon()
self.update_Rn_Re()
def update_Rn_Re(self):
self.Rn=self.R*(1-(self.e**2))/(1-(self.e**2)*(math.sin(self.Latitude))**2)**1.5
self.Re=self.R/(1-(self.e**2)*(math.sin(self.Latitude))**2)**0.5
def move_view(self, direction, degree_per_step):
Vn = degree_per_step / 180.0 * math.pi * math.cos(direction / 180.0 * math.pi)
Ve = degree_per_step / 180.0 * math.pi * math.sin(direction / 180.0 * math.pi)
self.Latitude=self.Latitude+Vn/self.Rn
self.Longitude=self.Longitude+Ve/(self.Re*math.cos(self.Latitude))
self.constrain_lon()
self.update_Rn_Re()
return self.Longitude,self.Latitude
def constrain_lon(self):
if self.Longitude < -180.0:
self.Longitude += 360.0
if self.Longitude > 180.0:
self.Longitude -= 360.0