Angle Between Vectors Calculator – Degrees, Radians, and Cosine Similarity
The angle between two vectors tells you how far apart two directions are in space — a core computation in linear algebra, physics, computer graphics, and machine learning. This calculator finds the angle between vector A and vector B in 2D or 3D space, and reports the result simultaneously in degrees and radians, along with the underlying dot product, magnitudes, cosine value, and a plain-language relationship label.
The Angle Formula
The angle θ between two vectors is derived from the dot product identity A·B = |A|·|B|·cos θ. Rearranging for θ gives the formula this calculator uses:
cos(θ) = (A · B) / (|A| × |B|)θ = arccos(cos(θ))
Where the dot product and magnitudes are computed as:
- Dot product (2D):
A·B = Ax·Bx + Ay·By, or in 3D:A·B = Ax·Bx + Ay·By + Az·Bz - Magnitude:
|A| = √(Ax² + Ay² [+ Az²])
For example, A = (3, 4) and B = (1, 2) give A·B = 11, |A| = 5, and |B| ≈ 2.236, so cos(θ) ≈ 0.9839 and θ ≈ 10.30°.
Cosine Similarity
The value cos(θ) itself is often called cosine similarity — it ranges from 1 (vectors point in exactly the same direction) through 0 (perpendicular) down to -1 (vectors point in exactly opposite directions). Cosine similarity is widely used in natural language processing and machine learning to compare document embeddings, feature vectors, and recommendation profiles without being affected by vector magnitude — only direction matters.
Interpreting the Relationship Label
Beyond the raw angle, this calculator classifies the pair of vectors into one of five relationships:
- Parallel (0°): the vectors point in exactly the same direction.
- Acute (0°–90°): the vectors point in broadly similar directions.
- Perpendicular (90°): the dot product is zero — the vectors are orthogonal.
- Obtuse (90°–180°): the vectors point in broadly opposing directions.
- Opposite / anti-parallel (180°): the vectors point in exactly opposite directions.
Why the Cosine Value Is Clamped
cos(θ) a tiny fraction outside the valid range of [-1, 1] — for example 1.0000000002 — which would make arccos return NaN. This calculator clamps the cosine value to [-1, 1] before applying arccos, guaranteeing a valid angle every time.Handling the Zero Vector
If either vector A or vector B has zero magnitude (all components equal zero), the angle is mathematically undefined — there is no direction to measure an angle from. The calculator detects this case (magnitude below 1e-15) and shows a clear error instead of a misleading result.
Real-World Applications
- Physics: Finding the angle between two force vectors, or between a velocity vector and a surface normal.
- 3D graphics and game development: Comparing a camera's facing direction to a target, or a character's heading to a waypoint.
- Machine learning and NLP: Measuring cosine similarity between text embeddings or user/item feature vectors in recommendation systems.
- Chemistry: Estimating bond angles from atomic position vectors in molecular geometry.
- Robotics and navigation: Checking alignment between a sensor's heading vector and a target direction.
Using This Calculator
Switch between 2D and 3D mode, enter the components of vector A and vector B, and choose whether the primary result is displayed in degrees or radians — both units are always shown. In 2D mode, a diagram plots both vectors from the origin with an arc marking the angle between them. Expand the Step-by-Step Calculation panel to see the full formula substitution, adjust decimal precision from 0 to 10 places, and use the copy or share buttons to save your results or send a pre-filled link.