Audited 29 Jul 2026·Last updated 28 Oct 2026·4 citations·Tier 2·0 uses

Unit Vector Calculator

Normalise a 2D or 3D vector: get the unit vector in i, j, k form, the magnitude divided out, and the direction cosines and angles from each axis.

Unit Vector Calculator

Vector dimension
May be negative or zero. All components must be in the same unit.
May be negative or zero.
Used only in 3D mode. Ignored (treated as 0) when the dimension is set to 2D.
Unit vector û
0.6i + 0.8j
The vector of length 1 pointing the same way as v, written as i, j (and k) components to six decimal places.
Magnitude ‖v‖
5
û x component (cos α)
0.6
û y component (cos β)
0.8
û z component (cos γ)
0
Direction angle α from x-axis
53.1301°
Direction angle β from y-axis
36.8699°
Direction angle γ from z-axis
90°

Background.

A well-known bug in game programming lets a character walk diagonally about 41% faster than straight ahead. Pressing right and up together gives the direction (1, 1), whose length is √2 ≈ 1.4142, and if that is used as a velocity unchanged, the extra length turns into extra speed. Dividing (1, 1) by its own length gives (0.7071, 0.7071), which points the same way but has length exactly 1. That step is called normalising, and the result is a unit vector.

A unit vector carries direction and nothing else, which is why so much of physics, engineering and graphics is written with them. A force is its size times a unit vector along its line of action. A surface in a lighting calculation is described by a unit normal, because the brightness formula treats a dot product as the cosine of an angle, and that only works when both vectors have length 1. Text-search and recommendation systems normalise their vectors so that two items are compared by direction and not by how long the vectors happen to be.

The arithmetic is short: find the length, √(x² + y² + z²), and divide every component by it. Dividing by a positive number shrinks or stretches a vector without turning it, so nothing about its direction changes. The components you end up with have a second meaning. Each is the cosine of the angle between the vector and one of the axes, so the calculator also reports those three angles. The one vector that cannot be normalised is the zero vector, which has no length to divide by and no direction to keep.

What is unit vector calculator?

A unit vector is a vector of length 1; MathWorld notes it is sometimes called a direction vector. The unit vector in the direction of a non-zero vector v is û = v ÷ ‖v‖, where ‖v‖ is the magnitude. Its components are the direction cosines of v, cos α, cos β and cos γ, where α, β and γ are the angles between v and the positive x, y and z axes, and because û has length 1 they always satisfy cos²α + cos²β + cos²γ = 1. The unit vectors along the axes, î, ĵ and k̂, are the ones used to write results such as 0.6i + 0.8j.

How to use this calculator.

  1. Choose 2D for a vector in the plane or 3D for one in space. In 2D the z component is taken as exactly 0.
  2. Enter the components in one unit. Negative values and zeros are fine, as long as at least one component is not zero.
  3. Read the unit vector in i, j, k form, shown to six decimal places, with each component listed separately below it.
  4. Read the magnitude if what you needed was the vector's length; it is the number every component was divided by.
  5. Use the direction angles when you need the orientation relative to each axis, for example to resolve a force in a statics problem.

The formula.

û = v ⁄ ‖v‖ , ‖v‖ = √(x² + y² + z²)

‖v‖ = √(x² + y² + z²), the Pythagorean length of the vector, and û = (x ÷ ‖v‖, y ÷ ‖v‖, z ÷ ‖v‖). Multiplying a vector by the positive number 1 ÷ ‖v‖ changes its length to 1 and leaves its direction alone, so v can always be rebuilt as ‖v‖ × û. Each component of û is also a direction cosine: x ÷ ‖v‖ is the dot product of û with î, which equals cos α because both have length 1, and likewise for y and z. The angles are therefore α = arccos(x ÷ ‖v‖) and so on, each between 0° and 180°. That range means direction angles are unsigned. They say how far the vector is from each axis, not which side of it the vector lies on; the sign shows up instead in the angle from the other axes. In 2D the vector is treated as lying in the xy-plane, so its angle from the z-axis is always exactly 90°. The zero vector is refused, since its magnitude is 0 and û would be 0 ÷ 0.

A worked example.

Example

Take v = (3, 4). The magnitude is √(3² + 4²) = √(9 + 16) = √25 = 5, so the unit vector is (3 ÷ 5, 4 ÷ 5), shown as 0.6i + 0.8j. As a check, 0.6² + 0.8² = 0.36 + 0.64 = 1. The direction angles are arccos 0.6 = 53.1301° from the x-axis and arccos 0.8 = 36.8699° from the y-axis, and 90° from the z-axis because the vector lies flat in the plane. In three dimensions the same steps apply to v = (2, 1, −4). The magnitude is √(4 + 1 + 16) = √21 = 4.5826, giving û = 0.436436i + 0.218218j − 0.872872k. The angles from the axes are 64.1233°, 77.3956° and 150.7941°. The last is greater than 90° because the z component is negative: the vector points away from the positive z-axis.

vx3
vy4
vz0
dimension2

Frequently asked questions.

Why does (3, −4) have the same x-axis angle as (3, 4)?
Both make 53.1301° with the x-axis, one above it and one below. Direction angles come from arccos, which only returns 0° to 180°, so they measure how far from the axis a vector points, not on which side. The difference appears in the y-axis angle: 36.8699° for (3, 4) and 143.1301° for (3, −4). For a signed heading use the two-argument arctangent instead.
Do the x and y angles of a 2D vector always add to 90°?
Only when both components are positive. For (−3, 4) the angle from the x-axis is 126.8699° and from the y-axis 36.8699°, adding to 163.7398°. What always holds in 2D is cos²α + cos²β = 1, here 0.36 + 0.64.
What should code do when asked to normalise a zero vector?
Treat it as a special case. A zero vector has no direction, and dividing by its zero length gives 0 ÷ 0. Quietly returning (0, 0, 0) or a default direction hides the problem, which usually lies upstream: two identical points, a degenerate triangle or forces that cancelled. The calculator rejects it with a message instead.
Why don't my hand-rounded components square to exactly 1?
Usually because the magnitude was rounded before dividing. For (1, 2, 5) the length is √30 = 5.4772; rounding it to 5.48 first makes the squares of the components add to 0.9990. Keep the magnitude unrounded, or as √30, until the last step.
How do I get a vector of a chosen length in the same direction?
Multiply the unit vector by that length. Twelve units in the direction of (3, 4) is 12 × (0.6, 0.8) = (7.2, 9.6). This is how a fixed speed is applied along any heading, and it removes the diagonal-speed bug: normalise the input direction, then scale by the speed.
Do I need to normalise before finding the angle between two vectors?
Not separately. The usual formula, cos θ = (a · b) ÷ (‖a‖‖b‖), divides by both lengths, which is the same as normalising each vector and taking their dot product. Cosine similarity is that same quantity, which is why it ignores how long the vectors are.

How this page was produced

Published by
Quanta Calculator
Primary sources
4 cited below
Method
û = v ⁄ ‖v‖ , ‖v‖ = √(x² + y² + z²)
Published
Last verified

Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 1560 calculators remain free
  • No billing is enabled
Coming soon