Vector - Dot, Cross, Project, Angle
Use this vector calculator to run dot, cross, projection, angle, addition, subtraction, and normalization on 2D or 3D vectors in one pass.
Vector
Results
What Is a Vector Calculator?
A vector calculator is a single page that runs every common Cartesian vector operation on two input vectors a and b, so you do not have to rewrite seven different formulas by hand. Pick the operation (dot, cross, projection, angle, addition, subtraction, or normalization) and the dimension (2D or 3D), type the components, and the page returns the scalar or vector result plus the magnitudes of both inputs.
- • Linear algebra homework and exam prep: Confirm the dot, cross, or projection of two given vectors without rebuilding the formula each time, and use the result to check your own working step by step.
- • Physics and engineering preliminaries: Compute the angle between two forces or velocities, the projection of one onto another, or the cross product that drives a torque calculation.
- • Computer graphics and game math: Run dot and cross products on direction and normal vectors for lighting, facing, and right-handed coordinate systems, then normalize the result with the same form.
- • Quick sanity checks for code: Use the page as a reference implementation to compare against your own vector math functions in JavaScript, Python, C++, or any other language.
If you need a single-result reference for a specific operation, the dedicated single-operation pages in the same category cover that case with a more focused form.
If you only need the length of a single vector, the Vector Magnitude Calculator page covers that case with a more focused one-input form.
How the Vector Calculator Works
The page parses the two vectors, computes their magnitudes from the Pythagorean formula, then runs the selected operation on the components. The dot product adds the component-wise products, the cross product uses the determinant formula, the projection scales a by (a·b)/(a·a), and the angle comes from the arccosine of (a·b)/(|a||b|).
- a, b: Two input vectors as Cartesian components (ax, ay, az) and (bx, by, bz). In 2D mode z is treated as 0.
- |a|, |b|: Euclidean magnitudes, the square root of the sum of the squared components.
- a · b: Dot product (scalar product), equal to ax*bx + ay*by + az*bz.
- a × b: 3D cross product, equal to [ay*bz − az*by, az*bx − ax*bz, ax*by − ay*bx].
- theta: Angle between a and b, equal to arccos((a·b) / (|a|*|b|)) when both vectors are non-zero.
Floating-point error can push the cosine ratio very slightly above 1 or below -1. The page clamps the cosine to [-1, 1] before the arccosine so the angle stays well-defined.
Worked example: dot, cross, projection, and angle for a = [2,3,4] and b = [1,-2,3]
Vector a: (2, 3, 4). Vector b: (1, -2, 3).
a · b = 2*1 + 3*(-2) + 4*3 = 8. a × b = [3*3 − 4*(-2), 4*1 − 2*3, 2*(-2) − 3*1] = [17, −2, −7]. proj_a(b) = (8/29) * [2, 3, 4] = [16/29, 24/29, 32/29]. cos(theta) = 8 / sqrt(406) ≈ 0.3970, so theta ≈ 66.61 degrees.
a · b = 8, a × b = [17, −2, −7], proj_a(b) ≈ [0.5517, 0.8276, 1.1034], angle ≈ 66.61° (1.1625 rad).
The dot product is positive, so the two vectors make an acute angle. The cross product is perpendicular to both inputs with a magnitude equal to the area of the parallelogram they span.
According to Khan Academy, the dot product of two vectors a and b equals a_x*b_x + a_y*b_y + a_z*b_z and equals the product of the magnitudes times the cosine of the angle between them.
For a one-screen reference on the dot product alone, the Dot Product Calculator page is the faster one-form alternative.
Key Concepts Behind the Vector Operations
Four ideas cover every operation the page runs and explain when each one is the right operation to reach for.
Dot product (scalar product)
The dot product multiplies matching components and adds the results. It returns a single number, grows when the two vectors point in similar directions, and equals the product of the magnitudes times the cosine of the angle between them.
Cross product (3D only)
The cross product is a binary 3D operation that returns a third vector perpendicular to both inputs. Its magnitude is the area of the parallelogram the two inputs span, and its direction follows the right-hand rule, so swapping a and b changes the sign.
Vector projection
The projection of b onto a is the closest point to b that still lies on the line through a. It is computed as a scaled by (a·b)/(a·a), which keeps the scale factor dimensionless.
Angle between two vectors
The angle theta in [0, 180] degrees comes from arccos((a·b)/(|a||b|)). When the dot product is positive the angle is acute, when it is zero the vectors are perpendicular, and when it is negative the angle is obtuse.
Once these four ideas are clear, the rest of the page is just typing the components and reading the result. Projection and angle both depend on the dot product internally, and the supporting addition, subtraction, and normalization operations are simple component-wise algebra.
If you would rather see the magnitude, unit vector, direction cosines, and direction angles of a single 3D vector in one pass, the Vector Calculator page is the closest single-form alternative.
How to Use This Vector Calculator
Six short steps cover every operation and every dimension on the page, from a quick dot product to a 3D cross product.
- 1 Pick a dimension: Choose 2D to enter only x and y, or 3D to also include z. Switch the dimension later if you need the extra component for the cross product.
- 2 Enter vector a: Type ax, ay, and (in 3D) az. The defaults are (2, 3, 4) so the example starts from a generic 3D vector.
- 3 Enter vector b: Type bx, by, and (in 3D) bz. The defaults are (1, -2, 3) so the second vector points in a partially opposite direction in y.
- 4 Pick an operation: Use the Operation dropdown to choose dot, cross, projection, angle, addition, subtraction, or normalization.
- 5 Read the result: The primary result updates as you type. Dot product shows a single number, cross, projection, addition, subtraction, and normalization show a vector, and angle shows both degrees and radians.
- 6 Reset or change inputs: Click Reset to return to the example. The magnitudes of a and b are always shown so you can confirm the inputs and the result are consistent.
Try a = (1, 0, 0) and b = (0, 1, 0) in 3D with the angle operation. The dot product is 0, |a| = |b| = 1, and the angle is exactly 90 degrees. Change to Cross product and the result is (0, 0, 1).
When the 3D cross product is the only thing you need, the Cross Product Calculator page runs just the determinant formula on a single form.
Benefits of Using This Vector Calculator
These benefits matter most when you are switching between operations or trying to confirm a hand calculation without retyping components into a new tool.
- • Seven operations in one form: Dot, cross, projection, angle, addition, subtraction, and normalization all run from the same two input vectors, so you do not have to retype components when you switch operations.
- • Switch between 2D and 3D without losing work: The dimension dropdown swaps the z-component rows in and out of the form. The x and y values you typed stay put.
- • Always-on supporting outputs: |a|, |b|, and the dot product are computed for every operation. That makes the result easy to cross-check against a textbook answer or your own code.
- • Clean handling of edge cases: The page refuses to compute a cross product in 2D, refuses to normalize the zero vector, and refuses to take the angle when either input is the zero vector, with a clear error message in each case.
- • Works as a learning aid: The page shows the magnitudes alongside the chosen operation, so you can see the role of |a| and |b| in the dot product, projection, and angle formulas in one place.
The page is most useful as a single front door for vector arithmetic. Use it to confirm a homework answer, sanity-check a graphics calculation, or pre-validate a vector pair before you hand it to a longer physics or linear-algebra script.
If you only need to add two vectors, the Vector Addition page is the most direct one-screen option for the component-wise sum.
Factors That Affect the Vector Result
The component formulas are stable in every case, but a few factors change how the result should be read or which operations are even defined.
Order of the two vectors
The dot product is symmetric, so a · b equals b · a. The cross product is anti-symmetric, so b × a is the negative of a × b. Addition, subtraction, and projection are not symmetric.
Dimension of the input vectors
Addition, subtraction, dot product, and projection all work in 2D and 3D. The cross product only makes sense in 3D; in 2D the page refuses to run it and asks you to switch the dimension.
Magnitude of the input vectors
Normalize, projection, and angle all divide by |a|, |a|², or |a||b|. When the relevant input is the zero vector the page returns a clear error instead of a misleading number.
Floating point and rounding
cos(theta) can drift slightly outside [-1, 1] when a and b should be parallel or anti-parallel. The page clamps the cosine before arccos so the angle stays in [0, 180] degrees.
- • The page is the Cartesian case only. It does not handle vectors written in polar or spherical form; convert to components first or use the dedicated vector direction page.
- • The cross product is 3D only. In 2D the page returns a clear error and points you to the 3D option rather than silently producing a scalar perpendicular to the plane.
- • Floating point drift in cos(theta) is clamped, but the four-decimal precision means very small angles will still round to 0 if they are below about 0.00005 degrees.
According to Wolfram MathWorld, the cross product a × b in three dimensions equals [a_y*b_z − a_z*b_y, a_z*b_x − a_x*b_z, a_x*b_y − a_y*b_x], a vector perpendicular to both inputs with magnitude equal to the area of the parallelogram they span.
According to Wikipedia, the vector projection of b onto a equals (a·b / a·a) times a, which matches the form used on this page.
When you would rather start from a magnitude and a direction than from Cartesian components, the Vector Direction Calculator page handles the conversion the other way.
Frequently Asked Questions
Q: What is a vector?
A: A vector is a quantity with both magnitude and direction, written as an ordered list of components such as (2, 3, 4) in 3D. The components say how far the vector reaches along each axis; the magnitude is its overall length; the direction is the way it points.
Q: How do you compute the dot product of two vectors?
A: Multiply matching components, then add the products. For a = (ax, ay, az) and b = (bx, by, bz), the dot product is a·b = ax*bx + ay*by + az*bz. The result is a single number, positive when the two vectors point in similar directions and zero when they are perpendicular.
Q: How do you compute the cross product of two vectors?
A: In 3D, the cross product is a × b = (ay*bz − az*by, az*bx − ax*bz, ax*by − ay*bx). The result is a vector perpendicular to both inputs with magnitude equal to the area of the parallelogram they span. Order matters: b × a is the negative of a × b.
Q: How do you find the angle between two vectors?
A: Compute the dot product, the two magnitudes, and take theta = arccos((a·b) / (|a|*|b|)). The result is in [0, 180] degrees. If either vector is the zero vector the angle is undefined because the division by |a| or |b| has no answer.
Q: How do you project one vector onto another?
A: The projection of b onto a is the closest point to b that still lies on the line through a. It is computed as proj_a(b) = (a·b / a·a) * a. The scalar factor (a·b / a·a) is dimensionless, and the page returns both that scalar and the resulting vector.
Q: Can the angle between two vectors be greater than 180 degrees?
A: No. The arccosine function returns a value in [0, 180] degrees by definition, so the angle between two non-zero vectors in Euclidean space is always between 0 and 180 degrees. Vectors that point in opposite directions give an angle of exactly 180.