Direction Angle of a 2D Vector

θ=atan2(vy,  vx)\theta = \operatorname{atan2}(v_y,\; v_x)

Enter your known values, leave one input blank, and solves for the missing one. Try different units for next level excitement!

Learning zone

Components tell you where a vector ends; the direction angle tells you which way it leans. Since tan θ = vy/vx, the naive answer is arctan(vy/vx) — and that answer is wrong half the time. The ratio for (−3, −4) is identical to the ratio for (3, 4), so a plain arctan reports a vector pointing southwest as though it pointed northeast. The fix is the two-argument function atan2(vy, vx), which keeps both signs and returns the true bearing anywhere in the full −180° to 180° sweep. It entered programming through early Fortran and is now in every standard library precisely because the quadrant bug was so pervasive.

Example: (−1, 1) points up and to the left, and atan2(1, −1) = 135° — correct, where arctan(1/−1) = −45° would have been off by exactly half a turn. Read the other way, a vector known to lie at 30° with vx = 10 must have vy = 10 tan 30° ≈ 5.774. Straight up or straight down the tangent blows up, which is the arithmetic's honest way of saying a vertical vector has no run to divide by.

Direction Angle of a 2D Vector
θ=atan2(vy,  vx)\theta = \operatorname{atan2}(v_y,\; v_x)
Where
  • θ\theta= Direction angle from +x axis
  • vxv_x= x-component
  • vyv_y= y-component