Vector Calculator

Compute magnitude, dot and cross products, angle between vectors, and projections in 2D or 3D, with formulas and geometric interpretation.

Core Math & Algebra

Interactive vector operations (2D & 3D)

Use this tool to explore vector algebra: magnitudes, dot product, angle between vectors, sum and difference, projection of one vector onto another, and (in 3D) the cross product and its magnitude (area).

Vector A

Empty fields are treated as 0. For 2D vectors, z is implicitly 0.

Vector B

You can model 2D vectors in 3D by setting z = 0.

What is a vector?

A vector is a quantity that has both magnitude (length) and direction. In coordinates, a 2D vector is written as \(\mathbf{v} = (x, y)\), and a 3D vector as \(\mathbf{v} = (x, y, z)\).

Vectors are fundamental in physics, engineering, and computer graphics. They model, for example:

  • Displacement between two points in space
  • Velocity and acceleration
  • Forces acting on a body
  • Surface normals and directions of light rays in 3D rendering

Vector magnitude (length)

The magnitude (or norm) of a vector \(\mathbf{v} = (x, y)\) in 2D is:

\[ \|\mathbf{v}\| = \sqrt{x^2 + y^2}. \]

In 3D, for \(\mathbf{v} = (x, y, z)\), the magnitude is

\[ \|\mathbf{v}\| = \sqrt{x^2 + y^2 + z^2}. \]

This calculator applies these formulas directly to the components you enter.

Dot product and angle between vectors

For vectors \(\mathbf{a}\) and \(\mathbf{b}\) in 2D or 3D, the dot product is:

\[ \mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y \quad (\text{2D}) \] \[ \mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y + a_z b_z \quad (\text{3D}). \]

Geometrically, the dot product relates to the cosine of the angle \(\theta\) between the vectors:

\[ \mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\|\,\|\mathbf{b}\| \cos \theta. \]

When neither vector is zero, you can solve for the angle:

\[ \theta = \arccos \left( \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\|\,\|\mathbf{b}\|} \right). \]

The calculator reports \(\theta\) in both radians and degrees, and carefully handles rounding so that the value inside \(\arccos\) stays within \([-1, 1]\).

Vector projection of A onto B

The scalar projection of \(\mathbf{A}\) onto \(\mathbf{B}\) is the component of \(\mathbf{A}\) along the direction of \(\mathbf{B}\):

\[ \operatorname{comp}_{\mathbf{B}}(\mathbf{A}) = \frac{\mathbf{A} \cdot \mathbf{B}}{\|\mathbf{B}\|}. \]

The vector projection of \(\mathbf{A}\) onto \(\mathbf{B}\) is

\[ \operatorname{proj}_{\mathbf{B}}(\mathbf{A}) = \frac{\mathbf{A} \cdot \mathbf{B}}{\|\mathbf{B}\|^2}\,\mathbf{B}, \quad \text{for } \mathbf{B} \ne \mathbf{0}. \]

This is exactly what the calculator computes and displays in coordinate form.

Cross product and area (3D)

For 3D vectors, the cross product \(\mathbf{A} \times \mathbf{B}\) is defined as:

\[ \mathbf{A} \times \mathbf{B} = \begin{pmatrix} a_y b_z - a_z b_y \\ a_z b_x - a_x b_z \\ a_x b_y - a_y b_x \end{pmatrix}. \]

Its magnitude is

\[ \|\mathbf{A} \times \mathbf{B}\| = \|\mathbf{A}\|\,\|\mathbf{B}\| \sin \theta, \]

which equals the area of the parallelogram spanned by \(\mathbf{A}\) and \(\mathbf{B}\). The calculator shows the full cross product vector and its magnitude in 3D mode.

Vector calculator – FAQ

How do I know if two vectors are perpendicular?

If the dot product \(\mathbf{a} \cdot \mathbf{b}\) is zero and neither vector is the zero vector, then the vectors are perpendicular (orthogonal). The tool checks this automatically with a small numerical tolerance and reports the relationship.

How can I tell if two vectors are parallel?

In 3D, vectors are parallel or anti-parallel if their cross product is the zero vector. In 2D, you can check whether their components are proportional. The calculator combines these checks with the sign of the dot product to distinguish between same-direction and opposite-direction parallelism.

What if one of the vectors is the zero vector?

If \(\mathbf{A} = \mathbf{0}\) or \(\mathbf{B} = \mathbf{0}\), the direction and angle between vectors are undefined, and projections onto the zero vector do not make sense. The tool handles these cases gracefully and explains when a quantity cannot be computed.

Can I use this for 4D or n-dimensional vectors?

This particular implementation focuses on 2D and 3D vectors, which cover most geometric and physics applications. The underlying formulas generalize naturally to higher dimensions, but the cross product as a vector is specific to 3D (and some more advanced settings).

How precise are the results?

All computations use standard double-precision floating-point arithmetic. The interface rounds values to a reasonable number of decimal places for readability. Minor rounding differences are expected and do not affect qualitative conclusions such as orthogonality or parallelism at typical tolerances.

Frequently Asked Questions

How should I interpret the angle between vectors?

The angle is always reported between 0° and 180°. An angle near 0° means the vectors point in almost the same direction, around 90° means they are nearly perpendicular, and close to 180° means they point in opposite directions.

Why do some results show “–” instead of a number?

This happens when a quantity is undefined, for example the angle when one vector is the zero vector, or the projection onto the zero vector. In such cases, the calculator leaves the value blank and describes the issue in the relationship summary.

Can I use this calculator for physics problems?

Yes. Many physics quantities such as displacement, velocity, force, and momentum are vectors. As long as you correctly translate your problem into vector components, this tool can help you analyze magnitudes, directions, and components along or perpendicular to a given direction.