Exemple #1
0
 def testHeadingLongFlag(self):
     '''
     Test that the plane execute veering in the right direction.
     '''
     self.plane.velocity = U.heading_to_v3(90).normalized() * 300 / 3.6
     self.pilot.do([('HEADING', [180], ['LONG'])])
     self.plane.update(5)
     self.assertFalse(U.heading_in_between([90,180], self.plane.heading))
Exemple #2
0
 def testHeading2Vector(self):
     '''
     heading_to_v3 - normalized vector pointint towards heading"
     '''
     TO_TEST = [(  0, ( 0,  1, 0)),
                ( 90, ( 1,  0, 0)),
                (180, ( 0, -1, 0)),
                (270, (-1,  0, 0)),
                (360, ( 0,  1, 0)),
                ( 45, (1/2**0.5, 1/2**0.5, 0))
                ]
     for heading, xyz in TO_TEST:
         res = U.heading_to_v3(heading)
         tuples = zip(res.xyz, xyz)
         for a, b in tuples:
             self.assertAlmostEqual(a,b)
Exemple #3
0
 def __get_crossed_gates(self, plane):
     '''
     Return the list of gates (if any) that a given point of the edge on
     the aerospace corresponds to.
     '''
     crossed = []
     origin = Vector3(S.RADAR_RANGE, S.RADAR_RANGE)
     point = Vector3(*plane.position.xy)
     for gate in self.gates.values():
         vector = U.heading_to_v3(gate.radial)
         dist = U.distance_point_line(point, origin, vector)
         boundaries = ((plane.heading - S.GATE_TOLERANCE) % 360,
                       (plane.heading + S.GATE_TOLERANCE) % 360)
         if dist <= gate.width / 2 and \
            U.heading_in_between(boundaries, gate.radial) and \
            gate.bottom <= plane.altitude <= gate.top:
             crossed.append(gate)
     return crossed
Exemple #4
0
 def __init_entry_data(self):
     '''
     Create the data that will be used to create aeroplanes at the right
     position on the map.
     '''
     gates_data = []
     for gate in self.scenario.gates:
         position = Vector3(*gate.location)
         velocity = U.heading_to_v3((gate.heading + 180)%360)
         levels = range(gate.top, gate.bottom-500, -500)
         levels = [l for l in levels if l%1000 == 500]
         gates_data.append((gate.name, position, velocity, levels))
     ports_data = []
     for port in self.scenario.airports:
         position = port.location.copy()
         position.z = -1  #-1 --> not on radar
         velocity = Vector3()
         ports_data.append((port.iata, position, velocity))
     self.__entry_data = dict(gates=gates_data, airports=ports_data)