Math

Vector Calculator

Calculate vector addition, dot and cross products, magnitude, unit vectors, the angle between vectors, projection and the scalar triple product in two or three dimensions.

Last reviewed by the Radiatus Cloud team

Results appear here.

Need this done properly for your business?

Radiatus delivers secure cloud, DevOps & compliance engineering.

Book a free consult

Two products that mean different things

The dot product returns a number and measures how much two vectors point in the same direction. It is zero exactly when they are perpendicular, which makes it the standard test for orthogonality, and it is what computes work done by a force and lighting intensity in graphics. The cross product returns a vector perpendicular to both, with a length equal to the area of the parallelogram they span. It exists only in three dimensions, and it gives torque, angular momentum and surface normals.

Normalisation is where numerical trouble starts

Dividing a vector by its own length gives a unit vector pointing the same way, which is required by almost every geometric algorithm. It fails for the zero vector, which has no direction to preserve, and becomes numerically unstable for a vector whose length is very small relative to the precision available. Graphics and physics code that does not check for this produces silent NaN values that propagate through everything downstream and surface far from the cause.

The angle formula loses precision near zero and 180 degrees

Computing the angle by taking the inverse cosine of the normalised dot product is correct and inaccurate for nearly parallel or nearly opposite vectors, because the cosine is flat there and small rounding errors in the dot product translate into large angular errors. Using the two argument arctangent of the cross product magnitude and the dot product is stable across the whole range, and it is the formula used here.

Related tools

  • Percentage Calculator — Calculate percentages, percentage change, increase and decrease, and reverse percentages, with the working shown for each result.
  • Statistical Calculator — Calculate mean, median, mode, standard deviation, and more.
  • Probability Calculator — Calculate probabilities for single and combined events, including conditional probability and Bayes' theorem.
  • Scientific Calculator — Perform advanced mathematical operations including trig, log, and exponents.

Frequently Asked Questions

What does the dot product measure?

How much two vectors point in the same direction. It is zero exactly when they are perpendicular, positive when the angle is acute and negative when it is obtuse, which makes it the standard test for orientation as well as orthogonality.

Why does the cross product only exist in three dimensions?

Because in three dimensions there is exactly one direction perpendicular to two given vectors, up to sign. In two dimensions there is no such direction within the plane, and in higher dimensions there is a whole subspace rather than a single direction.

What is a unit vector for?

Representing a direction with the length divided out, which nearly every geometric algorithm requires. Normalising the zero vector is undefined, and normalising a very short vector is numerically unstable, both of which produce NaN values that propagate silently.

Why not use the inverse cosine for the angle?

Because the cosine is flat near zero and 180 degrees, so a small rounding error in the dot product becomes a large angular error there. The two argument arctangent of the cross product magnitude against the dot product is stable across the whole range.

What is the scalar triple product?

The dot product of one vector with the cross product of two others. Its absolute value is the volume of the parallelepiped the three vectors span, and it is zero exactly when they are coplanar, which makes it the standard test for that.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Enter two vectors to compute their products, angle, projection and related quantities.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.