Vector Calculator
Analyze any vector from its components. Enter the x, y and z values (leave z at 0 for a 2D vector) to get the magnitude, the unit vector, and the direction angle or direction angles.
Example: with x component 3 · y component 4 · z component 0 → Magnitude |v|: 5 (2D vector).
- Unit vector (v/|v|)(0.6, 0.8, 0)
- Direction53.1301° from +x axis
Computed by the calculator below using its default values. Change any input to see your own numbers.
Magnitude uses |v| = √(x²+y²+z²). The unit vector divides each component by that length, so it always has magnitude 1 and points the same way.
What the numbers describe
A vector is a quantity with both size and direction. The magnitude is its length, found with the Pythagorean theorem extended to as many axes as the vector has: square each component, add them, take the square root. For (3, 4) that is √(9+16) = 5.
The unit vector strips away the length and keeps only the direction. Dividing each component by the magnitude gives a vector of length exactly 1 pointing the same way, which is what you use whenever you need direction without size — surface normals, headings, or the axis of a rotation.
2D versus 3D direction
In two dimensions a single angle from the positive x-axis fully describes direction, measured counterclockwise with atan2. In three dimensions one angle is not enough, so the direction is given as three angles, one to each axis. Their cosines are the components of the unit vector, which is why they are called direction cosines.
How it’s calculated
Magnitude |v| = √(x²+y²+z²). Unit vector = (x/|v|, y/|v|, z/|v|). For a 2D vector (z = 0) the direction is θ = atan2(y, x) measured counterclockwise from the +x axis and reported in degrees. For a 3D vector the direction angles to the x, y and z axes are acos(x/|v|), acos(y/|v|) and acos(z/|v|).
Components are treated as exact Cartesian coordinates in a right-handed system. The zero vector has a defined magnitude of 0 but no direction.
Magnitude and unit vector for sample inputs
| Components (x, y, z) | Magnitude | Unit vector |
|---|---|---|
| (3, 4, 0) | 5 | (0.6, 0.8, 0) |
| (1, 2, 2) | 3 | (0.333, 0.667, 0.667) |
| (2, 3, 6) | 7 | (0.286, 0.429, 0.857) |
| (0, 0, 5) | 5 | (0, 0, 1) |
Computed with |v| = √(x²+y²+z²) and unit vector = v/|v|; rounded.
Common mistakes
- Adding components instead of squaring them — magnitude is √(x²+y²+z²), not x+y+z.
- Forgetting the z term when a vector is genuinely 3D, which understates the length.
- Reporting the unit vector without dividing by the full magnitude, so it does not actually have length 1.
- Mixing up degrees and radians when reading the direction angle.
Frequently asked questions
What is the formula for the magnitude of a vector?
The magnitude is |v| = √(x²+y²+z²): square every component, add them, and take the square root. For a 2D vector the z term is simply 0.
How do I find the unit vector?
Divide each component by the magnitude. The result points in the same direction but has length exactly 1, so it carries direction without size.
What does the direction output mean?
For a 2D vector it is the angle counterclockwise from the positive x-axis. For a 3D vector it is three angles, one to each axis, whose cosines equal the unit-vector components.
Can a vector have a negative magnitude?
No. Magnitude is a length and is always zero or positive. Direction, not sign, tells you which way the vector points.