0
$\begingroup$

I am trying to figure out how to get the heading of a wind with U and V components, using a Vector Triangle. I have been trying to study the bottom of http://www.aprweather.com/pages/wind.htm and still just don't get how to actually get the heading.

Given a U and a V componenent, where V is the Y axis and U is the X axis, how could I get the heading (in 360 degrees) of a line where U or V can be a positive or negative number?

2 Answers 2

1

As your linked page says, you need to take the arctangent of the ratio of the two components. Which you divide by depends on where you want to measure the angle from and in which direction.

But argtangent will only give you an angle based on half a circle ($\pi$ radians or $180^\circ$). The two-argument function atan2 will extend the result to a full circle ($2\pi$ radians, so you may want to multiply the result by $\frac{180}{\pi}$ to get degrees) but you still have the issue of where you want to measure the angle from and in which direction, plus the complication of different spreadsheets and programming languages having different conventions, so you need to experiment.

0

Pardon my math n00biness in this question, after much thought, I found

    if ucomp > 0 and vcomp > 0:         heading = 360 - angle     else if ucomp > 0 and vcomp < 0:         heading = 90 - angle     else if ucomp < 0 and vcomp < 0:         heading = 180 - angle     else if ucomp < 0 and vcomp > 0:         heading = 270 - angle 

to be the best way to work with U and V comps. Psuedocode for the programmers =)