Exemplo n.º 1
0
        /// <summary>
        /// Calculate the distance depending on the flight time
        /// </summary>
        /// <param name="flightTime">Flight duration in hour</param>
        /// <param name="plane">Plane indicator</param>
        /// <returns>Distance of the flight (going only in Km)</returns>
        public static Double DistanceFromFlightTime(Double flightTime, ViewModels.PlaneViewModel plane)
        {
            if (Math.Abs(flightTime) < Double.Epsilon || plane.Speed == 0)
            {
                return(0);
            }

            Double airTime = (flightTime - 2) / 2;

            return(airTime * plane.Speed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculate the flight time depending on the distance
        /// </summary>
        /// <param name="distance">Distance of the flight (going only in Km)</param>
        /// <param name="plane">Plane indicator</param>
        /// <returns>Flight duration in hour</returns>
        public static Double FlightTimeFromDistance(Double distance, ViewModels.PlaneViewModel plane)
        {
            if (Math.Abs(distance) < Double.Epsilon || plane.Speed == 0)
            {
                return(0);
            }

            Double time   = distance / plane.Speed * 2.0;
            Int32  hour   = ((Int32)time) + 2;
            Double minute = Math.Ceiling((time % 1) * 60.0 / 15.0) * 15.0 / 60.0;

            return(hour + minute);
        }