add functions to calculate other speeds, etc
This commit is contained in:
@@ -132,11 +132,10 @@ class WeatherModel:
|
||||
else:
|
||||
self.LastWeatherUpdate = None
|
||||
|
||||
def calculateGS(self, altitude : int, ias : int, heading : int):
|
||||
def interpolateWindData(self, altitude : int):
|
||||
self.updateWindModel()
|
||||
tas = self.calculateTAS(altitude, ias)
|
||||
|
||||
# initialize the wind data
|
||||
# initialized the wind data
|
||||
if None != self.WindDirectionModel and None != self.WindSpeedModel:
|
||||
direction = 0.0
|
||||
speed = 0.0
|
||||
@@ -151,5 +150,32 @@ class WeatherModel:
|
||||
speed = 0
|
||||
direction = 0
|
||||
|
||||
# calculate the ground speed based on the headwind component
|
||||
return speed, direction
|
||||
|
||||
def calculateGS(self, altitude : int, ias : int, heading : int):
|
||||
speed, direction = self.interpolateWindData(altitude)
|
||||
tas = self.calculateTAS(altitude, ias)
|
||||
return tas + speed * math.cos(math.radians(direction) - math.radians(heading))
|
||||
|
||||
def convertGSToTAS(self, altitude : int, gs : int, heading : int):
|
||||
speed, direction = self.interpolateWindData(altitude)
|
||||
return gs - speed * math.cos(math.radians(direction) - math.radians(heading))
|
||||
|
||||
def estimateCourse(self, altitude : int, gs : int, heading : int):
|
||||
tas = self.convertGSToTAS(altitude, gs, heading)
|
||||
speed, direction = self.interpolateWindData(altitude)
|
||||
|
||||
aca = heading - direction
|
||||
wca = speed * aca / tas
|
||||
|
||||
if 0 <= aca:
|
||||
course = heading + wca
|
||||
else:
|
||||
course = heading - wca
|
||||
|
||||
while 0 > course:
|
||||
course += 360
|
||||
while 360 < course:
|
||||
course -= 360
|
||||
|
||||
return course
|
||||
|
||||
Reference in New Issue
Block a user