Ejemplo n.º 1
0
 public Aircraft(string callsign, Position position, double airspeed, double altitude, double heading)
 {
     this.callsign = callsign;
     this.position = position;
     this.airspeed = airspeed;
     this.altitude = altitude;
     this.heading = heading;
 }
Ejemplo n.º 2
0
 public double distanceTo(Position position)
 {
     double R = EARTH_RADIUS_KM;
     double φ1 = DegreesToRadians(latitude), λ1 = DegreesToRadians(longitude);
     double φ2 = DegreesToRadians(position.latitude), λ2 = DegreesToRadians(position.longitude);
     double Δφ = φ2 - φ1;
     double Δλ = λ2 - λ1;
     double a = Math.Sin(Δφ / 2) * Math.Sin(Δφ / 2) +
                Math.Cos(φ1) * Math.Cos(φ2) *
                Math.Sin(Δλ / 2) * Math.Sin(Δλ / 2);
     double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
     double d = R * c;
     return d * KM_TO_NM;
 }
Ejemplo n.º 3
0
 public Wind windAtPosition(Position position)
 {
     Wind wind = new Wind();
     double closest = Double.MaxValue;
     foreach (WeatherStation station in stations)
     {
         double distance = station.position.distanceTo(position);
         if (distance < closest)
         {
             closest = distance;
             wind = station.wind;
         }
     }
     return wind;
 }
Ejemplo n.º 4
0
 public void updatePosition(double milliseconds)
 {
     double distance = this.groundspeed * milliseconds / Position.KM_TO_NM / Position.MS_IN_HR;
     this.position = this.position.destinationPoint(heading + this.position.magneticDeclination(altitude), distance);
 }