Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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 =)

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.