Working on programming my own E6B and am stuck trying to calculate the following problem from Sporty's E6B:
Given wind info and desired speed/course, what airspeed/heading should I have in order to maintain the desired speed/course mentioned?
Example:
Inputs:
- Wind Direction = 60
- Wind Speed = 14
- Desired Course = 43
- Desired Ground Speed = 100
Outputs:
- True Airspeed required = 113.5
- Heading required = 45
I have already solved the required Heading part by doing the below (this is JS code):
windAngleRad = toRadians(windDirection - course);
crosswind = windSpeed * Math.sin(windAngleRad);
headwind = windSpeed * Math.cos(windAngleRad);
tas = Math.sqrt(Math.pow(groundSpeed - headwind, 2) + Math.pow(crosswind, 2)); (THIS GIVES WRONG ANSWER)
driftAngleRad = Math.atan(crosswind / (groundSpeed - headwind));
heading = course + toDegrees(driftAngleRad);
toRadians/toDegrees do the obvious, Math.pow is exponent, Math.atan is arctan
I have seen images like the one below, which make it seem like I have everything I need, but I am not sure how to solve the theoretical missing side of this triangle (TAS & HDG).
Trigonometry is not my area of expertise, so I believe that is what I am missing here. The only reason I have the code above done is that I saw a breakdown of solving it online. People ask how to calculate GS from TAS but not the other way around... seems like required True Airspeed is not something people seem to be calculating very often.
With that being said, if anyone could help me understand how to solve this, I would greatly appreciate it.