Vector Dot Product Calculator – Scalar Product, Angle, and Projection
The dot product (also called the scalar product) is one of the two fundamental ways to multiply vectors, alongside the cross product. Unlike vector addition or the cross product, the dot product of two vectors always returns a single scalar number rather than another vector. This calculator computes the dot product of two vectors in 2D or 3D space, along with the magnitude of each vector, the angle between them, a perpendicularity check, and the scalar projection of one vector onto the other.
The Dot Product Formula
For two vectors A and B, the dot product is calculated by multiplying corresponding components and summing the results:
- 2D:
A·B = Ax·Bx + Ay·By - 3D:
A·B = Ax·Bx + Ay·By + Az·Bz
For example, if A = (3, 4) and B = (1, 2), then A·B = 3×1 + 4×2 = 11. In 3D, if A = (1, 2, 3) and B = (4, 5, 6), then A·B = 1×4 + 2×5 + 3×6 = 32.
Magnitude of a Vector
The magnitude (or length) of a vector is derived from the Pythagorean theorem: |A| = √(Ax² + Ay² [+ Az²]). Both magnitudes are required to compute the angle between the vectors and the scalar projection, so the calculator always displays|A| and |B| alongside the dot product.
Finding the Angle Between Two Vectors
The dot product is closely tied to the angle θ between two vectors through the identity A·B = |A|·|B|·cos θ. Rearranging for θ gives:
θ = arccos( (A·B) / (|A|·|B|) )
For instance, A = (1, 0) and B = (0, 1) gives A·B = 0, so cos θ = 0 and θ = 90°. The calculator reports this angle in both degrees and radians.
Perpendicularity Check
Two vectors are perpendicular (orthogonal) exactly when their dot product equals zero, since cos(90°) = 0. This calculator automatically flags perpendicular vector pairs with a badge, which is a quick way to verify orthogonality without manually solving for the angle.
Scalar Projection of A onto B
The scalar projection measures how much of vector A points in the direction of vector B. It is calculated as:
proj_B(A) = (A·B) / |B|
For example, with A = (3, 4) and B = (1, 0), the dot product is 3 and |B| = 1, so the scalar projection of A onto B is 3. This concept underlies vector decomposition, work calculations in physics, and shadow/lighting computations in computer graphics.
Handling the Zero Vector
If either vector A or vector B has a magnitude of zero (all components are zero), the angle and scalar projection become mathematically undefined because the formulas require dividing by |A|·|B| or |B|. The calculator detects this condition and displays a clear warning instead of an incorrect or misleading value, while still reporting the dot product (which is always 0 in that case) and the magnitudes.
Real-World Applications
- Physics — work done by a force: Work equals the dot product of the force vector and the displacement vector,
W = F·d, capturing only the component of force in the direction of motion. - Computer graphics and game engines: Dot products determine lighting intensity (via the angle between a surface normal and a light direction) and are used extensively in collision detection and camera view calculations.
- Engineering projections: Engineers use scalar projections to resolve forces or velocities along a specific axis or direction of interest.
- Machine learning: Dot products underlie cosine similarity, a common metric for comparing feature vectors and embeddings.
Using This Calculator
Toggle between 2D and 3D mode at the top, enter the components of vector A and vector B, and results update live as you type. Expand the Step-by-Step Calculation panel to see the substituted formula, 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 to a colleague or classmate.