## Flight Planning

### January 19, 2010

[ We studied methods of computing sines in a previous exercise. In today's exercise, guest author Jos Koot, a retired physicist, amateur pilot, and Scheme enthusiast, gives us an example of the use of sines. Feel free to contact me if you have an idea for an exercise, or if you wish to contribute your own exercise. Jos writes this disclaimer: Do not use the example program for real life flight planning. It may not be fool proof!!! Use more appropriate equipment and procedures after studying aeronautics more profoundly. I do not accept any claims. There is a lot more to flying than presented in this exercise. ]

When preparing to fly, a pilot must know:

• The direction and distance from the airfield of departure to the airfield of destination. This direction is called the ground track (GT).
• The name (WN) and speed (WS) of the wind. The name is the direction from which the wind blows and is measured in degrees clockwise from north. The direction proper (WD) is opposite to that of the name.
• The air speed of the plane (AS) This is the speed of the airplane relative to the moving air.

Directions are measured in degrees clockwise from geographic north, 360 degrees on the compass-card. You may measure distances and times in any unit you like. Speeds should be in unit of distance per unit of time, of course. We take the air speed as a given datum and we ignore time needed for climbing and descending. Because the plane may be drifted by the wind, the pilot must calculate which direction to head for in order to compensate the drift. For this purpose the pilot may draw a triangle whose sides are speeds:

• Ground track. This side is to be drawn in the direction from takeoff to destination but with unknown speed. This still unknown speed is called the ground speed (GS).
• Drift caused by the wind. Both direction and speed are known thanks to meteorologists. The drift points in the direction the wind blows to and is opposite to that of the name of the wind. For example, wind from east causes drift to west.
• True heading (HT). This is the direction the pilot must choose in order to compensate for the drift. The direction is unknown, but the speed is: it is the air speed, also called the cruise speed.

It is instructive first to draw some navigation triangles by means of a pair of compasses and a ruler. The air speed is significantly greater than the wind speed, of course. First draw a line in the direction of the ground track. On this line choose a point B. Draw the drift ending in point B. Now we have point C. Draw a circle with point C for its centre and the air speed for its radius. The circle has two points of intersection with the ground track. One of the intersection points is A. Point A and the other point of intersection correspond to the two roots of the quadratic equation. Because the ground speed is directed from point A to point B it is not difficult to see which point of intersection is the right one. Now the vector equation AB = AC + CB is satisfied.

The known data are: ground track GT, distance (D) from departure to destination, wind name WN, wind velocity WS and the air speed AS. The air speed is significantly greater than the velocity of the wind, of course. From these data we want to compute: true heading TH, ground speed GS and time of the flight (FT=D/GS).

One solution uses the law of sines, which states that the ratio of the length of a side to the sine of the opposite angle is the same for all three sides of any triangle. We have $\frac{AS}{\sin\ B} = \frac{WS}{\sin\ A} = \frac{GS}{\sin\ C}$, hence $TH = GT + A = GT + \sin^{-1}(\frac{WS \sin\ B}{AS})$. The ground speed can be calculated as $GS = AS \cos(TH - GT) + WS \cos\ B$.

Another solution uses the cosine rule c² = a² + b² – 2ab cos(θ) to compute the third side of a triangle when two sides and the included angle are known, a quadratic equation is obtained. Solving this equation for the unknown ground speed, we have $GS = WS \cos\ B \pm \sqrt{WS^2 \cos^2 B - WS^2 + AS^2}$. Because we want a positive ground speed, take the root with the plus sign. Finally use the cosine rule again in order to compute the angle of correction (angle A), which is the angle between the ground track and the required true heading: $A = \cos^{-1} \frac{AS^2 + GS^2 - WS^2}{2 GS AS}$, so the true heading is $TH = GT \pm A$. This angle must be added or subtracted from the direction of the ground track depending on which side the wind drifts the plane.

Your task is to write two functions, as above, that take a distance, ground track, wind speed and direction, and air speed and computes the true heading, ground speed, correction and duration of flight. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

### 2 Responses to “Flight Planning”

1. [...] Praxis – Flight Planning By Remco Niemeijer In today’s Programming Praxis exercise we have to implement two algorithms for flight [...]

2. Remco Niemeijer said

import Data.Fixed

toDeg, toRad :: Floating a => a -> a
toDeg d = d * 180 / pi
toRad d = d * pi / 180

navigate1 :: Float -> Float -> Float -> Float -> Float -> [Int]
navigate1 d gt wn ws as = map round [gs, a, th, ft] where
b  = toRad $gt - wn + 180 a = toDeg$ asin (ws * sin b / as)
th = mod' (gt + a) 360
gs = (cos . toRad $th - gt) * as + ws * cos b ft = d / gs * 60 navigate2 :: Float -> Float -> Float -> Float -> Float -> [Int] navigate2 d gt wn ws as = if det < 0 || gs < 0 then error "strange" else map round [gs, a, th, ft] where b = mod' (gt - wn + 180) 360 x = ws * cos (toRad b) det = x^2 - ws^2 + as^2 gs = x + sqrt det a = (if b < 180 then id else negate) . toDeg . acos$
(as^2 + gs^2 - ws^2) / (2 * gs * as)
th  = gt + a
ft  = d / gs * 60