[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]




Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.


Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 


We receive a few cents from each purchase.  Thanks


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)


Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only




A simulation program for an aircraft instrument simulator called the Horizontal Situation Indicator is under development here at DFF.   This Wind Triangle program was written to make sure that I understood the concepts and mathematics for navigating an aircraft in the desired direction.      

Objects moving though still air generally move in the direction they are pointed. However moving air, i.e. the wind, will alter the course and speed of the object relative to the ground depending on the wind direction and speed.

Correcting for the wind is a necessary skill for airplane pilots, expert marksmen, and successful golfers. Only airplanes generally fly slow enough and high enough that mathematically calculating the wind correction angle is worthwhile. The technique uses "vector addition". Vectors are line segments that have a specific direction, i.e. they are defined by a length and an angle. In our Wind Triangle we'll have three vectors:

bulletThe Wind vector defined by Wind Direction and Windspeed.  
bulletThe Heading vector defined by the Heading Angle and Airspeed. This is the path that the plane would take in still air.
bulletThe Track or Course vector defined by the Course Angle and speed (Groundspeed) of the plane over the ground.  It's the result of the Wind vector acting on the Heading vector.

Note that speeds substitute for distances here which is OK since they are directly proportional.  Under constant input conditions, whether you fly for one minute or one hour, the distances traveled will be in proportion to the speeds  and the triangle will have exactly this same shape whichever variable is plotted.    

WTA=Wind to track Angle

WCA= Wind Correction Angle 

In most cases, we want the Course to be an input and calculate the proper heading into the wind to offset its effect.  Search the web for "Plot Wind Triangle" and you will find a number of pages describing the geometric construction technique.

This program  provides an interactive version that uses trigonometry to determine the Heading that will keep us on the desired Course. Playing with it will help develop an understanding of how the variables interact. A summary of the equations used is given for each output.


The Equations

 We are given 4 values as input.  (Wind direction, Wind speed,  Airspeed and Desired Course Angle).   This is the minimum required to define the triangle and orient it in relative to North.   Here are the essential equations used to calculate the missing parameters for our Wind Triangle: .  

Wind Direction Adjustment

WindDir = Input WindDirection +180 

Since Wind directions are given as "From" direction rather than "To", we'll add 180 degrees to get our vector point in the correct  (downwind) direction..

Wind To Track Angle:

WTAngle =  DesiredCourse - WindDir 

The input angles Wind direction (WinDir) and Desired Course (DesiredCourse) are fixed angles independent of any other values.  The difference is calculated as a convenience  in references in the equations below.

Wind Correction Angle


We'll define the Wind Correction Angle (WCA) to be the angle that our Heading Angle  must deviate from the DesiredCourse to correct for the effect the the Wind is having on our aircraft.  

The Sine Rule in trigonometry  says that  lengths of the sides of a triangle are in the same proportion as the sine of the angles opposite those sides.  I.e. If one side is twice as long as another, the sine of the angle opposite the longer side will be twice as large as the sine of the angle opposite the shorter side. For our triangle this implies that : Sin(wca)/windspeed = sin(WTAngle)/airspeed which leads to the above equation .



By definition the Wind Correction Angle is the angle between the Heading and the Desired CourseWCA = Heading - DesiredCourse  which leads directly to the above equation.


groundspeed = airspeed*cos(WCA) + windspeed*cos(WTAngle)

We'll use the definition of Cosine (Cosine=adjacent side/hypotenuse) to calculate the length of the groundspeed vector.  By dropping an altitude from the vertex opposite the course side, we can divide our Wind triangle into two right triangles as shown here.   The sum of the two adjacent pieces is the groundspeed. 

We  also have enough information to use the Sine Rule or the Cosine Rule to calculate groundspeed.  All three methods produce the same answer,  but the equation used here is slightly less cumbersome.  

Addendum: October 13, 2006:   Since publishing the Wind Triangle program in February, 2005,  I have had several pilots inquire about implementing an Excel spreadsheet version.   The typical problem they had was not realizing that the trig functions require  angles to be specified in radians instead of degrees.   (Also true in Delphi and most other languages.)  Patrick C. recently sent his "Flight Planning Worksheet"  Excel file and I  fixed his calculation for True Heading and Ground Speed..  With his kind permission, I decided to make it available for downloading as a prototype for the  next pilot  working on the problem.     Patrick lives in New Zealand (and flies a Cessna). They measure fuel in liters and, at least in his spreadsheet, distance and speed in nautical miles and knots.   The fuel, speed, and distance calculations would not change for  other measurement systems. 

Addendum February 10, 2010:  An option was added today allowing users to change the colors used for text backgrounds and fonts, and for  plotting the Wind Triangle vectors.   Some of my original color choices are made it difficult for those who are color blind to use the program.

Running/Exploring the Program 

Download source code

Download executable 

Download Excel Flight Planning Worksheet


Created: February 5, 2005

Modified: May 15, 2018


  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2018, Gary Darby    All rights reserved.