Angle Between Two Vectors Calculator

Vector a

Vector b

Angle between the vectors62.19 degrees
Angle in radians1.0854
cos(angle)0.4666
How this was calculated
  1. Dot product = 8.00, with |a| = 3.7417 and |b| = 4.5826.
  2. cos(angle) = 8.00 / (3.7417 x 4.5826) = 0.4666.
  3. Angle = arccos(0.4666) = 62.19 degrees (1.0854 radians).

The angle between two vectors calculator finds the angle formed by any two vectors in 2D or 3D space. It uses the dot product relationship, cos(theta) = (a . b) / (|a| |b|), to deliver an angle always between 0 and 180 degrees. For example, vectors a = (1, 2, 3) and b = (4, -1, 2) have a dot product of 8.00, magnitudes of 3.7417 and 4.5826, a cosine of 0.4666, and an angle of 62.19 degrees, which equals 1.0854 radians. The x and y unit vectors (1, 0, 0) and (0, 1, 0) produce a dot product of 0 and an angle of exactly 90.00 degrees, while a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, give a cosine of 1.0000 and an angle of 0.00 degrees.

The dot product method is the accepted standard because it is both mathematically exact and computationally efficient. The dot product's sign alone classifies the angle: a zero dot product means perpendicular vectors, a positive dot product means an acute angle, and a negative dot product means an obtuse angle. Because floating-point rounding can push the cosine a hair outside [-1, 1] for nearly parallel vectors, the calculator clamps it before taking arccos, otherwise the result would be NaN. This page shows the formula, step-by-step workings, worked examples, and sources.

Worked examples

An acute angle

Primary result: 62.19 degrees — a dot product of 8.00 against magnitudes 3.7417 and 4.5826. (1 · 2 · 3 · 4 · -1 · 2)

Angle between the vectors62.19 degrees
Angle in radians1.0854
cos(angle)0.4666

Exactly perpendicular

Primary result: 90.00 degrees — the x and y unit vectors have a dot product of zero. (1 · 0 · 0 · 0 · 1 · 0)

Angle between the vectors90.00 degrees
Angle in radians1.5708
cos(angle)0.0000

Parallel vectors

Primary result: 0.00 degrees — b is exactly twice a, so the cosine is 1.0000. (3 · 4 · 0 · 6 · 8 · 0)

Angle between the vectors0.00 degrees
Angle in radians0.0000
cos(angle)1.0000

What the angle between vectors means

The angle between two vectors is simply the smaller of the two angles formed where their directions meet. It always falls between 0 and 180 degrees, which means it can never be a reflex angle. The math behind this comes from the dot product: cos(theta) = (a . b) / (|a| |b|). This formula gives the one angle in that 0-to-180 range, and an angle between two vectors calculator uses it directly. For example, with a = (1, 2, 3) and b = (4, -1, 2), the dot product is 8.00, the magnitudes are 3.7417 and 4.5826, the cosine is 0.4666, and the angle is 62.19 degrees, or 1.0854 radians.

The sign of the dot product alone tells you a lot about the angle before you ever compute it. A zero dot product means the vectors are perpendicular, which is why the x and y unit vectors (1, 0, 0) and (0, 1, 0) have a dot product of 0 and an angle of exactly 90.00 degrees. A positive dot product means an acute angle, while a negative one means an obtuse angle. When two vectors point in the same direction, the angle is 0.00 degrees. For instance, a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, give a cosine of 1.0000 and an angle of 0.00 degrees.

This angle matters in several practical fields. In physics and engineering, it determines how much of one force acts along the direction of another, which is central to work and projection problems. In computer graphics, the angle between a surface normal and a light direction controls how bright a surface appears. In navigation, it tells you how far off course one heading is from another. In data science, a small angle between two feature vectors signals that the items they represent are similar, while an angle near 90 degrees signals little similarity and an angle near 180 degrees signals opposition.

One technical detail is worth noting: for nearly parallel vectors, floating-point rounding can push the computed cosine a hair outside the valid range of -1 to 1. If that happens, the arccos function would return NaN instead of a number. To prevent this, the calculator clamps the cosine to the range [-1, 1] before taking arccos, so the result is always a real angle between 0 and 180 degrees.

A zero dot product means perpendicular vectors; a positive dot product means an acute angle and a negative one an obtuse angle — the dot product's sign alone classifies the angle.

The formula: from dot product to angle

The angle between two vectors comes from the dot product: cos(theta) = (a . b) / (|a| |b|). This relationship gives an angle always between 0 and 180 degrees. Once you compute the cosine, you take the arccosine to recover the angle itself. That is exactly what happens inside an angle between two vectors calculator: it evaluates the dot product, divides by the product of the magnitudes, and then applies arccos to return the result in degrees or radians.

Consider the verified case of a = (1, 2, 3) and b = (4, -1, 2). The dot product a . b equals 8.00. The magnitudes are 3.7417 for a and 4.5826 for b. Dividing the dot product by the product of the magnitudes gives a cosine of 0.4666. Taking the arccosine of 0.4666 yields an angle of 62.19 degrees, which equals 1.0854 radians. Every step follows directly from the formula, and the result sits comfortably between 0 and 180 degrees.

The dot product's sign alone classifies the angle before you even compute it. A zero dot product means perpendicular vectors. A positive dot product means an acute angle. A negative dot product means an obtuse angle. For example, the x and y unit vectors (1, 0, 0) and (0, 1, 0) have a dot product of 0 and an angle of exactly 90.00 degrees. In contrast, a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, have a cosine of 1.0000 and an angle of 0.00 degrees because the vectors point in the same direction.

One practical detail matters in implementation. Floating-point rounding can push the cosine a hair outside the range from -1 to 1 for nearly parallel vectors. If that happens, taking arccos would return NaN instead of a valid angle. To prevent this, the calculator clamps the cosine to the valid range before applying arccos. This step ensures the tool always returns a meaningful angle, even when the vectors are almost identical or almost opposite in direction.

Worked examples

The angle between two vectors comes from the dot product: cos(theta) = (a . b) / (|a| |b|), giving an angle always between 0 and 180 degrees. A zero dot product means perpendicular vectors; a positive dot product means an acute angle and a negative one an obtuse angle — the dot product's sign alone classifies the angle. The three verified cases below show how an angle between two vectors calculator handles acute, perpendicular, and parallel vectors.

In the first case, a = (1, 2, 3) and b = (4, -1, 2) have a dot product of 8.00, magnitudes 3.7417 and 4.5826, a cosine of 0.4666 and an angle of 62.19 degrees (1.0854 radians). The positive dot product confirms an acute angle before any trigonometry is applied. In the second case, the x and y unit vectors (1, 0, 0) and (0, 1, 0) have a dot product of 0 and an angle of exactly 90.00 degrees, which matches the perpendicular classification from the zero dot product. In the third case, a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, have a cosine of 1.0000 and an angle of 0.00 degrees, confirming the vectors are parallel and point in the same direction.

Floating-point rounding can push the cosine a hair outside [-1, 1] for nearly parallel vectors, so the calculator clamps it before taking arccos — otherwise the result would be NaN. This safeguard matters most when the dot product and the product of magnitudes are nearly equal in value, as small rounding errors can produce a cosine such as 1.0000001 or -1.0000001. Clamping forces the value back into the valid range so the arccosine function returns a usable angle of 0.00 degrees or 180.00 degrees instead of failing entirely. The verified cases in the table avoid this issue because the numbers are exact, but real-world inputs often require the clamp to produce a reliable result.

Vector aVector bDot product (a . b)Magnitude |a|Magnitude |b|cos(theta)Angle (degrees)Angle (radians)Classification
(1, 2, 3)(4, -1, 2)8.003.74174.58260.466662.191.0854Acute
(1, 0, 0)(0, 1, 0)0——090.00—Perpendicular
(3, 4, 0)(6, 8, 0)———1.00000.00—Parallel

Reading the dot product's sign

The angle between two vectors comes from the dot product: cos(theta) = (a . b) / (|a| |b|), giving an angle always between 0 and 180 degrees. But before you ever compute an arccosine, the dot product's sign alone tells you which category the angle falls into. A positive dot product means an acute angle, a zero dot product means the vectors are perpendicular, and a negative dot product means an obtuse angle. In many problems, that classification is all you actually need, and our angle between two vectors calculator saves you the extra step by showing the dot product alongside the final angle.

Consider the verified example of a = (1, 2, 3) and b = (4, -1, 2). Their dot product is 8.00, which is positive, so you already know the angle is acute without any further calculation. Carrying the math through confirms this: the magnitudes are 3.7417 and 4.5826, the cosine is 0.4666, and the angle is 62.19 degrees, or 1.0854 radians. The sign told you the angle would be less than 90 degrees before you touched a calculator. Now compare that with the x and y unit vectors (1, 0, 0) and (0, 1, 0), whose dot product is 0. That single zero tells you the vectors are perpendicular, and the full calculation confirms an angle of exactly 90.00 degrees.

A negative dot product works the same way in reverse. If the dot product comes out negative, the angle is obtuse, meaning greater than 90 degrees but no more than 180. You can state that immediately and move on. When the dot product is positive and the vectors point in nearly the same direction, the angle shrinks toward zero. The verified pair a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, shows this extreme: the cosine is 1.0000 and the angle is 0.00 degrees. Here the dot product is positive and as large as it can be relative to the magnitudes, so the vectors are parallel and pointing the same way.

One practical note: floating-point rounding can push the cosine a hair outside the range of negative one to positive one for nearly parallel vectors. If that happened and you took the arccosine directly, the result would be NaN, not a number. The calculator clamps the cosine to stay within that range before taking the arccos, so the result is always a real angle between 0 and 180 degrees. The dot product's sign still does the quick classification work, but the clamping step ensures the precise numeric output is reliable even in edge cases where rounding threatens to break the math.

Degrees or radians?

The angle between two vectors comes from the dot product: cos(theta) = (a . b) / (|a| |b|), giving an angle always between 0 and 180 degrees. Our angle between two vectors calculator defaults to degrees, since most users find degrees more intuitive for visualizing angles. You can switch the output to radians with a single toggle if your work requires it.

The same angle looks different in each unit. For example, the vectors a = (1, 2, 3) and b = (4, -1, 2) have a dot product of 8.00, magnitudes of 3.7417 and 4.5826, a cosine of 0.4666, and an angle of 62.19 degrees. That same angle equals 1.0854 radians. The calculator shows both values so you do not need a separate conversion step.

Converting between the two is straightforward. To go from degrees to radians, multiply by pi and divide by 180. To go from radians to degrees, multiply by 180 and divide by pi. The calculator handles this automatically, but knowing the relationship helps you sanity-check results. A 90.00 degree angle, such as the one between the x and y unit vectors (1, 0, 0) and (0, 1, 0), equals approximately 1.5708 radians.

  • Degrees: the default output, best for everyday interpretation and most textbook problems.
  • Radians: the standard unit in physics, engineering, and higher mathematics.
  • Conversion: radians = degrees × pi / 180; degrees = radians × 180 / pi.
Floating-point rounding can push the cosine a hair outside the valid range of -1 to 1 for nearly parallel vectors, so the calculator clamps the value before taking arccos. Without this step, the result would be NaN. For instance, a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, produce a cosine of 1.0000 and an angle of 0.00 degrees.

Edge cases

Most inputs to an angle between two vectors calculator behave cleanly, but a few situations deserve attention because they can confuse users or break the underlying math. The first is the zero vector. Because a zero vector has no direction, there is no meaningful angle between it and any other vector. The formula divides by the product of the two magnitudes, so if either vector is zero the denominator becomes zero and the result is undefined. Any reliable calculator should detect this case up front and report that no angle exists rather than returning a misleading number.

A second edge case involves vectors that are nearly parallel. The angle between two vectors comes from the dot product: cos(theta) = (a . b) / (|a| |b|), giving an angle always between 0 and 180 degrees. When vectors point in almost the same direction, the cosine should sit very close to 1.0000. Verified testing confirms this: a = (3, 4, 0) and b = (6, 8, 0), where b is exactly twice a, have a cosine of 1.0000 and an angle of 0.00 degrees. The same logic applies in reverse for nearly opposite vectors, where the cosine should sit very close to -1.0000 and the angle should be 180 degrees.

The problem is that floating-point rounding can push that cosine a hair outside the valid range of -1 to 1 for nearly parallel vectors. A computed value of 1.0000000001 or -1.0000000001 may look harmless, but the arccos function is only defined for inputs between -1 and 1. Feeding it an out-of-range value produces NaN, which stands for "not a number" and is useless to anyone reading the result. To prevent this, the calculator clamps the cosine before taking arccos, forcing any value slightly above 1 down to exactly 1 and any value slightly below -1 up to exactly -1. This small step keeps rounding error from breaking the calculation.

It is also worth noting how the dot product's sign classifies the angle, which helps when interpreting borderline results. A zero dot product means perpendicular vectors, as verified by the x and y unit vectors (1, 0, 0) and (0, 1, 0), which have a dot product of 0 and an angle of exactly 90.00 degrees. A positive dot product means an acute angle and a negative one an obtuse angle. Verified testing with a = (1, 2, 3) and b = (4, -1, 2) shows a dot product of 8.00, magnitudes 3.7417 and 4.5826, a cosine of 0.4666 and an angle of 62.19 degrees (1.0854 radians), which is acute as the positive dot product predicts. Understanding these sign patterns gives users a quick way to sanity-check results before trusting them.

A zero vector has no direction and no angle. If either input is a zero vector, the calculator cannot compute a result because the magnitude in the denominator is zero.

FAQs

How do you find the angle between two vectors?

Take the dot product, divide by both magnitudes, and apply arccos. For example, with vectors (1, 2, 3) and (4, -1, 2), the verified angle is 62.19 degrees. The calculator handles each step automatically so you get accurate results without manual computation.

What does a dot product of zero mean?

A dot product of zero means the vectors are perpendicular. The verified unit-vector example gives exactly 90.00 degrees. When the dot product is zero, the arccos of zero equals 90 degrees, confirming the two vectors meet at a right angle.

Can the angle between vectors be more than 180 degrees?

No. The formula returns the smaller angle, always between 0 and 180 degrees. Parallel vectors give 0.00 degrees, as in the verified (3, 4, 0) and (6, 8, 0) case. The calculator never returns an angle larger than 180 degrees.

What is the angle between (1, 2, 3) and (4, -1, 2)?

The angle is 62.19 degrees, or 1.0854 radians. This comes from a dot product of 8.00 and magnitudes of 3.7417 and 4.5826. Dividing the dot product by the product of the magnitudes and applying arccos gives the verified result.

How do you know if the angle is acute or obtuse without calculating it?

Look at the dot product's sign. A positive dot product means the angle is acute, a negative dot product means it is obtuse, and a dot product of zero means exactly 90 degrees. This quick check tells you the angle type before computing the exact value.

Why does the calculator clamp the cosine?

Rounding can make the computed cosine 1.0000001 for nearly parallel vectors, and arccos of anything above 1 is undefined. Clamping keeps the answer at the correct 0.00 degrees, preventing errors and ensuring accurate results even when vectors are nearly parallel.

Sources

Related calculators

Vector Dot Product Calculator
The dot product of two 3D vectors, their magnitudes and the angle between them — and what the sign of the result tells you.
Cross Product Calculator
The vector perpendicular to two 3D vectors — components, magnitude and the parallelogram area it represents.
Vector Magnitude Calculator
The magnitude (length) of a 2D or 3D vector, its unit vector, and — in 2D — the direction angle, with the Pythagorean steps shown.
Slope Calculator
Slope, angle, distance and midpoint between two points, plus the full equation of the line through them — the whole coordinate-geometry answer in one go.