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

Angle Between Two Vectors Calculator

Find the angle between two 2D or 3D vectors from their components, in degrees and radians, with cos θ, the dot product, both lengths and a right-angle check.

Angle Between Two Vectors Calculator

Vector dimension
Vector a must not be the zero vector. The result is symmetric, so it does not matter which vector you call a.
Used only in 3D mode.
Vector b must not be the zero vector.
Used only in 3D mode.
Angle θ
27.266
The unsigned angle between a and b in degrees, from 0° to 180°; it is the same whichever vector you enter first.
Angle θ in radians
0.4759
Relationship
acute angle — the vectors point broadly the same way
cos θ
0.8889
Dot product a·b
8
Magnitude ‖a‖
3
Magnitude ‖b‖
3

Background.

The 109.47° between two bonds in a methane molecule, the 54.74° "magic angle" at which solid-state NMR samples are spun, and the misalignment between a robot's gripper and the bolt it has to grab are the same calculation. Each is the angle between two vectors, and each comes from one identity: the dot product of two vectors equals the product of their lengths times the cosine of the angle between them, a·b = ‖a‖‖b‖ cos θ.

The identity is useful because both sides can be worked out without drawing anything. The dot product is the sum of matching components multiplied together, and each length is a square root of a sum of squares. Divide one by the other, take the inverse cosine, and a geometric question turns into a handful of multiplications.

The answer always lies between 0° and 180°. It measures the smaller opening between the two directions, in whatever plane the pair shares, and it carries no sense of rotation, so swapping the vectors changes nothing. That suits questions like how far apart two directions are, or whether a force helps or resists a motion. It cannot tell you which way to turn; a directed angle in the plane, one that can be negative, comes from the two-argument arctangent instead.

The sign of the dot product settles the rough answer before any trigonometry. Positive means acute, zero means a right angle, negative means obtuse.

What is angle between two vectors calculator?

The angle between two non-zero vectors is the angle at which they meet when both are drawn from the same starting point, measured inside the plane the pair spans. By convention it runs from 0°, when they point the same way, through 90° when they are perpendicular, to 180° when they point in exactly opposite directions. Its cosine, (a·b) ÷ (‖a‖‖b‖), always lies between −1 and 1, a guarantee that follows from the Cauchy–Schwarz inequality. The zero vector has no direction, so it makes no angle with anything and is refused.

How to use this calculator.

  1. Pick 2D for vectors in a plane, written (x, y), or 3D for vectors in space. In 2D the z fields are ignored and both vectors lie flat.
  2. Type the components of a and b. If a vector is defined by two points, subtract the start from the end first: going from (1, 4, 0) to (3, 6, 1) is the vector (2, 2, 1).
  3. Neither order nor positive scale matters. (1, 2, 2) and (10, 20, 20) give identical angles, so you can clear fractions or decimals by multiplying a vector through by a positive number.
  4. Read the angle in degrees or radians, then the relationship line, which names the pair as parallel, antiparallel, perpendicular, acute or obtuse.
  5. Keep the dot product and the lengths if you also need a projection: the component of a along b is a·b ÷ ‖b‖.

The formula.

cos θ = (a·b) ⁄ (‖a‖ ‖b‖) , θ = arccos(cos θ)

θ = arccos[(a·b) ÷ (‖a‖‖b‖)], where a·b = ax·bx + ay·by + az·bz and ‖a‖ = √(ax² + ay² + az²), with ‖b‖ built the same way. In 2D the z terms are simply zero.

The identity comes from the law of cosines. In the triangle whose sides are a, b and a − b, the law of cosines gives ‖a − b‖² = ‖a‖² + ‖b‖² − 2‖a‖‖b‖ cos θ. Expanding the left side component by component gives ‖a‖² + ‖b‖² − 2 a·b. Matching the two leaves a·b = ‖a‖‖b‖ cos θ. Dividing by both lengths strips out size and leaves only direction, which is why stretching either vector by a positive factor leaves θ untouched, while reversing one turns θ into 180° − θ.

The two lengths are combined under a single square root, √(‖a‖²‖b‖²), and the cosine is held within −1 and 1 before the inverse cosine is taken. Exactly parallel inputs therefore give 0° rather than an error from a cosine that rounding nudged a hair past 1.

Near 0° and 180° the inverse cosine is very sensitive: a cosine of 0.9999999999 already corresponds to about 0.0008°. Small decimal errors in your components show up there first.

A worked example.

Example

Take a = (2, 2, 1) and b = (1, 2, 2) in 3D. The dot product multiplies matching components and adds them: 2 × 1 + 2 × 2 + 1 × 2 = 2 + 4 + 2 = 8. Both vectors have length 3, since √(2² + 2² + 1²) = √9 and √(1² + 2² + 2²) = √9 — two of the few integer vectors whose lengths come out whole. The cosine is 8 ÷ (3 × 3) = 8/9 ≈ 0.8889. Its inverse cosine is 0.4759 radians, which is 27.266°. The positive dot product had already said the angle would be acute, and the relationship line agrees. The same numbers give the projection without further work. The shadow that a casts along b has length 8 ÷ 3 ≈ 2.6667, about 89% of a's full length of 3, and that fraction is the cosine itself.

bx1
ax2
by2
ay2
bz2
az1
dimension3

Frequently asked questions.

Can the angle come out negative or bigger than 180°?
Not here. The inverse cosine only returns values from 0° to 180°, so the result is unsigned. For a directed angle in 2D use atan2(ax·by − ay·bx, ax·bx + ay·by). For a = (2, 2) and b = (1, 2) that gives +18.4349° turning from a to b and −18.4349° turning from b to a, while this calculator shows 18.4349° either way.
How can I check whether two vectors are perpendicular by hand?
Multiply matching components and add. If the total is zero, the vectors are at right angles, provided neither is the zero vector; no square roots or inverse cosines are needed. For example (3, −4, 0) and (4, 3, 7) give 12 − 12 + 0 = 0, so they are perpendicular even though they look nothing alike.
Where does the 109.47° bond angle of methane come from?
Put the carbon at the origin and two hydrogens along (1, 1, 1) and (1, −1, −1), two corners of a cube that sit at tetrahedral positions. The dot product is 1 − 1 − 1 = −1 and each length is √3, so cos θ = −1/3, and arccos(−1/3) = 109.4712°, the tetrahedral angle.
What does a negative dot product mean in physics?
The angle is obtuse, so the two vectors point broadly against each other. With force and displacement, the dot product is the work done, W = F·d, and a negative value means the force takes energy out of the motion. Friction on a sliding block and braking on a moving car both do negative work for that reason.
Is cos θ here the same thing as cosine similarity?
It is the same number, (a·b) ÷ (‖a‖‖b‖). Cosine similarity is usually applied to long lists such as word counts or text embeddings with hundreds of components, where nobody wants an angle in degrees. With only two or three components the question is usually geometric, so the angle comes first and gives the cosine alongside.
What happens if one vector is all zeros?
You get an error rather than a number. A zero vector has no direction, and the formula would divide by a length of zero, so any angle reported would be meaningless. If a zero vector turns up in real work, it usually means two points coincide or two forces cancelled, which is worth handling deliberately upstream.

How this page was produced

Published by
Quanta Calculator
Primary sources
4 cited below
Method
cos θ = (a·b) ⁄ (‖a‖ ‖b‖) , θ = arccos(cos θ)
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