Angle Between Two Vectors Calculator
Calculate the angle between two vectors in 2D, 3D, and nD space. Computes dot product, magnitudes, cosine theta, degrees, and radians with step-by-step steps.
How to Find the Angle Between Two Vectors
The angle between two vectors $\mathbf{u}$ and $\mathbf{v}$ is the shortest angle $\theta \in [0^\circ, 180^\circ]$ (or $[0, \pi]$ radians) between their directional line segments when placed tail-to-tail. In physics, linear algebra, robotics, and computer graphics, this angle determines relative orientation, directional alignment, field of view, lighting reflections (Lambertian shading), and forces.
The mathematical relationship is derived from the geometric definition of the dot product (inner product):
$$\mathbf{u} \cdot \mathbf{v} = \|\mathbf{u}\| \|\mathbf{v}\| \cos(\theta)$$
Solving for $\theta$ yields the standard formula:
$$\theta = \arccos\left(\frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\| \|\mathbf{v}\|}\right)$$
For further vector and matrix calculations, explore our Random Vector Generator, Eigenvalue Eigenvector Calculator, and Angle Converter.
Step-by-Step Calculation Formula
To find the angle between two $n$-dimensional vectors $\mathbf{u} = (u_1, u_2, \dots, u_n)$ and $\mathbf{v} = (v_1, v_2, \dots, v_n)$:
- Calculate the Dot Product: $$\mathbf{u} \cdot \mathbf{v} = \sum_{i=1}^n u_i v_i = u_1 v_1 + u_2 v_2 + \dots + u_n v_n$$
- Calculate the Euclidean Magnitudes: $$\|\mathbf{u}\| = \sqrt{u_1^2 + u_2^2 + \dots + u_n^2}, \qquad \|\mathbf{v}\| = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2}$$
- Compute the Cosine: $$\cos(\theta) = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\| \|\mathbf{v}\|}$$
- Compute the Inverse Cosine (Arccosine): $$\theta = \arccos(\cos(\theta))$$
- Convert Radians to Degrees: $$\theta^\circ = \theta \times \frac{180^\circ}{\pi}$$
Interpreting the Angle and Dot Product
| Angle ($\theta$) | $\cos(\theta)$ | Dot Product ($\mathbf{u} \cdot \mathbf{v}$) | Relationship |
|---|---|---|---|
| $\theta = 0^\circ$ | +1 | $\|\mathbf{u}\|\|\mathbf{v}\|$ | Parallel (same direction) |
| $0^\circ < \theta < 90^\circ$ | > 0 | > 0 | Acute angle |
| $\theta = 90^\circ$ | 0 | 0 | Orthogonal / Perpendicular |
| $90^\circ < \theta < 180^\circ$ | < 0 | < 0 | Obtuse angle |
| $\theta = 180^\circ$ | -1 | $-\|\mathbf{u}\|\|\mathbf{v}\|$ | Antiparallel (opposite direction) |
Worked Example (3D Space)
Let $\mathbf{u} = (2, 3, -1)$ and $\mathbf{v} = (1, -2, 4)$.
- Dot Product: $\mathbf{u} \cdot \mathbf{v} = (2)(1) + (3)(-2) + (-1)(4) = 2 - 6 - 4 = -8$.
- Magnitudes: $\|\mathbf{u}\| = \sqrt{2^2 + 3^2 + (-1)^2} = \sqrt{4 + 9 + 1} = \sqrt{14} \approx 3.7417$.
- $\|\mathbf{v}\| = \sqrt{1^2 + (-2)^2 + 4^2} = \sqrt{1 + 4 + 16} = \sqrt{21} \approx 4.5826$.
- Cosine: $\cos(\theta) = \frac{-8}{\sqrt{14}\sqrt{21}} = \frac{-8}{\sqrt{294}} \approx \frac{-8}{17.1464} \approx -0.4666$.
- Angle: $\theta = \arccos(-0.4666) \approx 2.0563 \text{ rad} \approx 117.81^\circ$. Since $\theta > 90^\circ$, the vectors form an obtuse angle.
Frequently Asked Questions
Can the angle between two vectors ever exceed 180 degrees?
No. By mathematical convention in Euclidean geometry and linear algebra, the angle between two vectors is always measured as the smaller angle between their rays, which lies strictly between 0 degrees and 180 degrees (0 and $\pi$ radians).
Why is the angle undefined for a zero vector?
A zero vector $\mathbf{0} = (0, 0, \dots, 0)$ has zero magnitude ($\|\mathbf{0}\| = 0$). Dividing by zero in the cosine formula creates an indeterminate expression $\frac{0}{0}$. Geometrically, a zero vector is a single point with no direction, so no angle can be formed.
What is the difference between 2D and 3D vector angle calculations?
The dot product formula $\theta = \arccos\left(\frac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{u}\|\|\mathbf{v}\|}\right)$ is universally identical across all dimensions (2D, 3D, 4D, and higher). The only difference is that higher dimensions include additional coordinate terms in the dot product sum and magnitude formula.
How do you test if two vectors are perpendicular?
Two non-zero vectors are perpendicular (orthogonal) if and only if their dot product equals exactly zero ($\mathbf{u} \cdot \mathbf{v} = 0$). This occurs because $\cos(90^\circ) = 0$.