A vector has a size and a direction. The direction angle is measured counter-clockwise from the positive x-axis; in 3D, the angles to each axis (direction cosines) describe it completely.
How to use the Direction of the Vector Calculator
- Dimension
- x
- y
- z
Results update as you type, and everything is calculated in your browser.
How it works
The magnitude is the square root of the sum of squared components. The 2D angle uses atan2, so vectors in every quadrant get the correct angle.
Inputs explained
| Field | What to enter |
|---|---|
| Dimension | Choose one: 2D, 3D |
| x | A number |
| y | A number |
| z | A number |
What each result means
- Direction angle θ (2D, from the x-axis) = mod(deg(atan2([y], [x])), 360)
- α (angle with the x-axis) = deg(acos([x]÷sqrt([x]^2 + [y]^2 + [z]^2)))
- β (angle with the y-axis) = deg(acos([y]÷sqrt([x]^2 + [y]^2 + [z]^2)))
- γ (angle with the z-axis) = deg(acos([z]÷sqrt([x]^2 + [y]^2 + [z]^2)))
- Unit vector – z = [z]÷sqrt([x]^2 + [y]^2 + [z]^2)
Example values
How the main result changes when x changes and everything else stays at the example values above:
| x | Direction angle θ (2D, from the x-axis) (°) |
|---|---|
| -1.5 | 110.556 |
| -2.25 | 119.3578 |
| -3 | 126.8699 |
| -3.75 | 133.1524 |
| -4.5 | 138.3665 |
| -6 | 146.3099 |
Formula
2D: θ = atan2(y, x) (adjusted to 0°–360°)
3D: cos α = x/|v|, cos β = y/|v|, cos γ = z/|v|
Worked example
Inputs — Dimension: 2D; x: -3; y: 4.
Results — Direction angle θ (2D, from the x-axis) = 126.869898 °; Magnitude |v| = 5; Unit vector – x = -0.6; Unit vector – y = 0.8.
Key terms
- Direction angle
- The angle a vector makes with the positive x-axis.
Frequently asked questions
What is the direction of (−3, 4)?
126.87° from the positive x-axis.
What are direction cosines?
cos α, cos β and cos γ – the components of the unit vector.
Why not use arctan(y/x)?
It gives the wrong quadrant for negative x; atan2 fixes that.
Do the direction cosines satisfy a rule?
cos²α + cos²β + cos²γ = 1.