Angle Between Two Vectors Calculator
Result
Angle between vectors
- Cosine of the angle
- 0.5000
- Angle in radians
- 1.0472
An angle between two vectors calculator takes two vectors and returns the angle between them, together with the cosine that angle came from and the same angle in radians. Type the components of each vector separated by spaces or commas — 1 1 0 for a three-dimensional vector, 0 3 for a two-dimensional one — and the page does the rest. The two vectors must have the same number of components, but there is no other limit on how many, and negative components are fine. The arithmetic behind the answer is short. Multiply the two first components together, the two second components, and so on, and add up the products: that is the dot product. Take the length of each vector, which is the square root of the sum of the squares of its components. Divide the dot product by the product of the two lengths and you have the cosine of the angle. The angle itself is the inverse cosine of that number. Working through the cosine rather than the angle directly is the whole trick, because the cosine is what the dot product naturally produces, and it is also the number worth looking at: it runs from 1 for two vectors pointing the same way, through 0 at a right angle, to −1 for two vectors pointing in opposite directions. Those three are the answers people actually recognise, and none of them needs a calculator to spot. Perpendicular vectors, the case the page is most often used for, are the ones with a cosine of exactly zero. Everything else lands somewhere in between, and the page reports it to four decimal places in degrees and in radians at once, since half the world's formulas want the second and most people read the first. One input is refused instead of answered: the zero vector, whose length is zero and which therefore has no direction at all. Dividing by its length to get a cosine would mean dividing by zero, and returning an angle of zero would be claiming it points the same way as your vector, so the page declines the whole calculation.
Vector pairs and the angle between them
| Vector u | Vector v | Cosine of the angle | Angle (°) |
|---|---|---|---|
| 1 1 0 | 1 0 1 | 0.5 | 60 |
| 1 0 | 0 1 | 0 | 90 |
| 1 0 0 | 1 0 0 | 1 | 0 |
| -1 0 0 | 1 0 0 | -1 | 180 |
| 1 1 | 1 0 | 0.7071 | 45 |
| 3 4 0 | 4 3 0 | 0.96 | 16.2602 |
| 1 2 2 | 2 2 1 | 0.8889 | 27.266 |
| 2 -3 | 4 5 | -0.3032 | 107.6501 |
Eight pairs, and the first row is the one the page loads with. The cosine column is the point of the table: the angle column alone hides the pattern, and with the cosine next to it the three special values stand out immediately. The first row is a cosine of exactly 0.5 giving exactly 60 degrees, and the sixth is a cosine of 0.96 giving 16.26 degrees — between those two rows is the whole warning about this page, that the cosine squeezes the range from 0 to 90 degrees into 1 down to 0 and squeezes it unevenly. The second row is the plainest right angle there is and the third is a vector against itself, giving the two ends of the cosine range, 0 and 1, with the fourth row supplying the third end at −1 by pairing a vector with its own negation. Those three rows together are the entire scale. The fifth row is a 45-degree pair, the half-right-angle that turns up constantly in practice, and the seventh is the untidy three-dimensional one: both lengths are exactly 3, but the dot product is 8, so the cosine is 8 ÷ 9 and repeats forever. The eighth row is an obtuse case with mixed-sign components: a cosine of −0.3032 and an angle of 107.6501, the two of them agreeing as they must, since a negative cosine and an angle under 90 degrees cannot both be right. The radian figure is deliberately not a column here — it is the same angle in another notation, and a fifth column would say nothing new. Every figure is recomputed when the page is built, and the spaces in the first two columns are the separators, not part of the numbers.
Formula
cos θ = (u · v) ÷ (|u| × |v|) θ = arccos(cos θ) u · v = u₁v₁ + u₂v₂ + … + uₙvₙ
- Vector u
- The first vector, written as its components separated by spaces or commas: 1 1 0 for three dimensions, 0 3 for two, or as many as you need. There is no fixed number of boxes because the page accepts any dimension, and the two vectors must have the same number of components as each other
- Vector v
- The second vector, written the same way and with the same number of components as the first. Swapping the two vectors changes nothing — the angle between them is the same either way round
- u · v
- The dot product, which this page uses but does not print: multiply the two first components, the two second components, and so on, and add up the products. It is the raw material of the angle rather than an answer in its own right here
- |u| and |v|
- The length of each vector, in whatever unit the components were measured in: the square root of the sum of the squares of its components. These are the two numbers the dot product is divided by, and they are each a vector's own business — one of them being large says nothing about the other
- cos θ
- The cosine of the angle between the two vectors: the dot product divided by the product of the two lengths. It runs from 1 for vectors pointing the same way, through 0 at a right angle, to −1 for vectors pointing in opposite directions, and it never leaves that range. This is the number the angle is actually computed from, which is why the page prints it
- θ
- The angle between the two vectors, in degrees, from 0 when they point the same way through 90 when they are perpendicular to 180 when they point in opposite directions. It is the inverse cosine of the number above, so it inherits its range and can never come back outside it
- Radians
- The same angle written the other way: 180 degrees is π radians, 90 is half of that, and the output is a plain number with no unit. Formulas in calculus and in most programming languages want radians, so the page gives both rather than making you multiply by π and divide by 180
- Degrees
- The unit of the main output, and the only output on the page that has a unit at all. The cosine and the radian figure are plain numbers
- Four decimal places
- How wide every output is written. The cosine is exact only in the special cases — 0, 0.5, 1 and −1 — and the angle is exact only when the cosine is one of those, so almost every row on this page carries rounded figures
This is the page for when you want the angle itself rather than just the relationship between two directions. Three angles are worth recognising without any arithmetic: a cosine of 1 means 0 degrees and the vectors point the same way, a cosine of 0 means 90 degrees and they are perpendicular, and a cosine of −1 means 180 degrees and they point in opposite directions. Anything else is a genuine angle and the page gives it to four decimal places. The commonest real use is checking a direction against a reference one — how far a wind has swung from due north, how far a camera has turned, how far a measured direction has drifted from the one it should have. Geometry problems with two known directions are the same calculation, and so is the angle between two lines once you have written each one as a vector. The useful sanity check on any answer is that the cosine and the angle must tell the same story: a cosine above zero always goes with an angle under 90 degrees, a negative cosine with one above it, and a cosine of zero with exactly 90. If the two disagree, the components are not what you thought they were. The radians output is there for the case where the angle is about to be fed into a formula or a line of code, since those almost always want radians, and converting by hand is where sign errors and factor-of-180 mistakes come from.
Worked examples
1 1 0 and 1 0 1
- Dot product: 1 × 1 + 1 × 0 + 0 × 1 = 1
- Length of u: √(1 + 1 + 0) = √2 = 1.414214
- Length of v: √(1 + 0 + 1) = √2 = 1.414214
- Cosine: 1 ÷ (1.414214 × 1.414214) = 1 ÷ 2 = 0.5
- Angle: the inverse cosine of 0.5 is 60 degrees, which is 60 × π ÷ 180 = 1.047198 radians
The input the page loads with, and the cleanest row there is: the cosine comes out as exactly one half and the angle as exactly 60 degrees. Notice that the dot product, 1, is nowhere on the panel — this page prints the cosine and the angle, and the dot product is the step in between. The two lengths are both the square root of two, so they multiply to exactly 2, which is why the cosine and the angle come out exact rather than rounded.
3 4 0 and 4 3 0
- Dot product: 3 × 4 + 4 × 3 + 0 × 0 = 24
- Length of each: √(9 + 16) = 5, since the third component is zero
- Cosine: 24 ÷ (5 × 5) = 0.96
- Angle: the inverse cosine of 0.96 is 16.2602 degrees, which is 0.2838 radians
The row that shows why the cosine is worth printing. A cosine of 0.96 sounds like two vectors that are almost identical, and the angle is 16.26 degrees — about a sixth of a right angle. The cosine squeezes the whole range from 0 to 90 degrees into the numbers between 1 and 0, and it does it unevenly, which is why reading the cosine off as a fraction of anything goes wrong. Both lengths are exactly 5 here, so the 3-4-5 triangle is doing its usual work.
1 0 and 0 1
- Dot product: 1 × 0 + 0 × 1 = 0
- Length of each: 1
- Cosine: 0 ÷ 1 = 0
- Angle: the inverse cosine of zero is exactly 90 degrees, which is 1.570796 radians
The answer the page is most often opened for, and the exact case: a cosine of zero means perpendicular vectors, and the angle comes back as exactly 90 rather than a rounded figure. These two are the plainest perpendicular pair there is, one along the x-axis and one along the y-axis. The radian figure, 1.5708, is π ÷ 2.
-1 0 0 and 1 0 0
- Dot product: (−1) × 1 + 0 × 0 + 0 × 0 = −1
- Length of each: 1
- Cosine: −1 ÷ 1 = −1
- Angle: the inverse cosine of −1 is exactly 180 degrees, which is 3.141593 radians
The other end of the range. A cosine of −1 is the largest angle two vectors can make, 180 degrees, and the radian figure is π. Two vectors pointing in exactly opposite directions are still two vectors, and the angle between them is not zero — this is the row to look at when an answer of 180 seems wrong. It is not: opposite is a relationship, the same way parallel is.
2 -3 and 4 5
- Dot product: 2 × 4 + (−3) × 5 = 8 − 15 = −7
- Length of u: √(4 + 9) = √13 = 3.605551
- Length of v: √(16 + 25) = √41 = 6.403124
- Cosine: −7 ÷ (3.605551 × 6.403124) = −7 ÷ 23.086793 = −0.303201
- Angle: the inverse cosine of −0.303201 is 107.6501 degrees, which is 1.8788 radians
An obtuse answer, which is the case that catches people out: two vectors can make an angle greater than 90 degrees, and they do whenever the dot product is negative. One component of u is negative here, which is how a vector pointing left or down is written. The cosine of −0.3032 is small but its sign is the whole message — it says the two vectors lean away from each other, and the angle of 107.6501 degrees agrees with it.
Limitations
The two vectors must have the same number of components, and a pair that does not match is refused rather than padded with zeros. The zero vector is refused entirely: a vector whose components are all zero has no direction, so the angle between it and anything else is undefined, and the page declines the whole calculation rather than showing an angle of zero that would read as pointing the same way. Components are read as ordinary numbers: a comma followed by a space separates components, a comma with no space after it is read as a decimal point (1,5 is one and a half), and a thousands grouping is refused rather than guessed at — write 1500, not 1,500. Up to 200 components are accepted in each vector, far beyond any hand-written case but short of the sizes a data pipeline would use. The dot product itself is not among the outputs, on purpose: it is the step the angle is computed from, and the page that prints it as an answer is a different one. Four decimal places is a display width rather than a claim about precision, and both outputs are computed from the unrounded lengths, so multiplying the printed figures back together may not reproduce the printed angle exactly. Nothing on the page knows what the components are measured in — the inputs are plain numbers, and so are the cosine and the radian figure, with degrees the only unit anywhere.
Frequently asked questions
- How do I type the components?
- Separate them with spaces or with a comma and a space: 1 1 0 and 1, 1, 0 both work. A comma sitting between two digits with no space after it is read as a decimal point (1,5 is one and a half); a thousands grouping such as 1,500 is refused rather than guessed at, so write 1500. The two vectors must have the same number of components, and there is no limit on how many as long as they match — two dimensions and three dimensions are the same page.
- What is the cosine of the angle for?
- It is the number the angle is computed from, and it is easier to read than the angle in the three cases that matter. A cosine of 1 means the vectors point the same way, 0 means perpendicular, and −1 means opposite. Anything in between is a real angle and the page gives it in degrees and in radians.
- How do I tell whether two vectors are perpendicular?
- Their cosine of the angle is zero, and the page will read exactly 90 degrees. That test needs none of the trigonometry the angle output uses — it is true precisely when the dot product is zero, which takes only the multiplications. This page shows the cosine so that the right-angle case is visible without working anything out.
- Why is the angle never more than 180 degrees?
- Because the cosine of the angle is bounded between −1 and 1, and the inverse cosine only returns values from 0 to 180 degrees. An angle of 180 degrees means the two vectors point in exactly opposite directions, and there is no such thing as an angle of 200 degrees between two directions — 200 and 160 describe the same pair of arrows.
- Why are there two angle outputs, degrees and radians?
- Because the two audiences are different. People read degrees; formulas and programming languages almost always want radians, and 180 degrees is π radians. Printing both means nobody has to multiply by π and divide by 180, which is where factor-of-180 mistakes come from. The radian figure is a plain number with no unit.
- Why does it refuse a vector of all zeros?
- Because the zero vector has no direction, so the angle between it and anything else is undefined. Its length is zero and the cosine is the dot product divided by the product of the two lengths, so working it out would mean dividing by zero. A page that returned 0 degrees would be saying it points the same way as your vector, which is a claim about a direction that does not exist.
References
- Dot product — the sum of the products of corresponding components, and the identity equating it to the two lengths times the cosine of the angle, which is the equation this page solves backwards — Wolfram MathWorld (United States)
- Vector — the object with a magnitude and a direction whose components this page reads, and whose length is the square root of the sum of the squares of those components — Wolfram MathWorld (United States)
- Perpendicular — the right-angle relation, the one case where the cosine is exactly zero and the angle exactly 90 degrees, and the reason this calculation is worth doing at all — Wolfram MathWorld (United States)
- 教育部关于印发义务教育课程方案和课程标准(2022 年版)的通知——The fifth item in the annex list of this notice is the Mathematics Curriculum Standards for Compulsory Education (2022 edition); plane vectors and their scalar product are part of the upper-secondary mathematics curriculum and do not fall in the compulsory-education grade bands, and the wording of the standards and the grade-band breakdown are governed by that annex — 中华人民共和国教育部