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
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.
- 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.
- 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).
- 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.
- Read the angle in degrees or radians, then the relationship line, which names the pair as parallel, antiparallel, perpendicular, acute or obtuse.
- 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.
θ = 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.
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.
Frequently asked questions.
Can the angle come out negative or bigger than 180°?
How can I check whether two vectors are perpendicular by hand?
Where does the 109.47° bond angle of methane come from?
What does a negative dot product mean in physics?
Is cos θ here the same thing as cosine similarity?
What happens if one vector is all zeros?
References& sources.
- [1]OpenStax, Calculus Volume 3 (2016 ed., web revision retrieved 2026-07-29), §2.3 ‘The Dot Product’ — Theorem 2.4 (u·v = ‖u‖‖v‖cos θ, hence cos θ = u·v/(‖u‖‖v‖)) and Theorem 2.5 (non-zero vectors are orthogonal if and only if u·v = 0). Open access.
- [2]OpenStax, University Physics Volume 1 (2016 ed.), §2.4 ‘Products of Vectors’ — Equation 2.27 (A·B = AB cos φ), Equation 2.33 (component form), Equation 2.34 (cos φ from components), and Example 2.16 ‘Angle between Two Forces’, which publishes F₁·F₂ = −162.4 N², cos φ = −0.439 and φ = 116.0°. This calculator reproduces every one of those figures.
- [3]Wolfram Research, MathWorld — ‘Dot Product’ (live revision retrieved 2026-07-29), Equation 1 (X·Y = |X||Y|cos θ) and Equations 8–10 (component form Σxᵢyᵢ).
- [4]Paul Dawkins, Paul's Online Notes (Lamar University), Calculus II — ‘Dot Product’, Example 2: the angle between ⟨3, −4, −1⟩ and ⟨0, 5, 2⟩ is 143.24°. Used as the independent cross-check for this page; the calculator returns 143.2441525165°, agreeing to every published digit.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- 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