3D Vector Dot Product, Cross Product & Angle Calculator

Evaluate 3D vector dot product, enclosed angle, and parallelogram area |A×B|.

Scalar Dot Product (A · B) 12
Angle Between Vectors (θ) 61.315 deg
Cross Product Magnitude |A × B| 21.932
Magnitude |A| 5
Inputs
Try:
Vector A x-component.
Vector A y-component.
Vector A z-component.
Vector B x-component.
Vector B y-component.
Vector B z-component.
Results & Graph
Scalar Dot Product (A · B)
12
Angle Between Vectors (θ)
61.315 deg
Cross Product Magnitude |A × B|
21.932
Magnitude |A|
5
Magnitude |B|
5

Scalar Dot Product (A · B)

Graph 1 • How the inputs feed 3D Vector Math
3D Vector Dot Product, Cross Product & Angle Calculator • Custom Domain Schematic (Coordinate & Vector Geometry) Invariants: ax, ay (3D Vector Math) Ax: 3 • Ay: 4 SCALAR DOT PRODUCT (A · B) 12 • Angle Between Vectors : 61.315 deg • Cross Product Magnitud: 21.932 Eq: A·B = a_xb_x + a_yb_y + a_zb_z;
Graph 2 • Scalar Dot Product (A · B) as Ax changes (40% to 160% of current)
0 10.56 21.12 4.80 1.20 7.20 1.80 9.60 2.40 12 3 14.40 3.60 16.80 4.20 19.20 4.80
Graph 3 • Ax and Ay together Compares Scalar Dot Product (A · B) when Ay is shifted +25% (solid) vs. −25% (dashed).
0 8.58 17.16 --- Ay @ 75% 8.40 -30% 10.20 -15% 12 +0% 13.80 +15% 15.60 +30%
Summary: A·B = 12, angle θ = 61.31°, and cross-product magnitude |A × B| = 21.9317.
Summary: A·B = 12, angle θ = 61.31°, and cross-product magnitude |A × B| = 21.9317.
Interactive chart & math engine powered by CalculatorGraph

Formula: 3D Vector Math Mathematical Identity

A·B = axbx + ayby + azbz
cos(θ) = A·B|A||B|
A·B = a_xb_x + a_yb_y + a_zb_z; cos(θ) = (A·B) / (|A||B|)
  • ax: Ax (numeric parameter)
  • ay: Ay (numeric parameter)
  • az: Az (numeric parameter)
  • bx: Bx (numeric parameter)
  • by: By (numeric parameter)
  • bz: Bz (numeric parameter)

Frequently Asked Questions

Why does the page refuse a vector of all zeros?

Because the angle to a zero vector is undefined: a zero vector has no direction, and the cosine formula would divide by zero. The page shows a message instead of a result and asks for at least one nonzero component in each vector. The dot product and cross magnitude would both be 0 in that case, so you can write those down yourself.

Does the order of A and B matter here?

Not for anything this page shows. The dot product, angle and magnitudes are symmetric, and swapping A and B only reverses the direction of the cross product, not its length. If you need the direction, compute A × B by hand. For the default it is (12, minus 9, minus 16), and B × A is (minus 12, 9, 16).

How do I get the area of a triangle in 3D from this?

Turn two sides into vectors from a shared corner, enter them as A and B, then halve the cross product magnitude. With the default vectors, the triangle with corners at the origin, (3, 4, 0) and (4, 0, 3) has area 21.932 divided by 2, or 10.966. Use corner differences, not raw coordinates, unless one corner is at the origin.

Can the dot product be bigger than both magnitudes?

Yes. It is the product of the lengths times the cosine, so it can be as large as |A| times |B|. With A = (3, 4, 0) and B = (6, 8, 0) the lengths are 5 and 10 and the dot product is 50. It can never exceed that product, because the cosine never exceeds 1. If your hand calculation does, check your arithmetic.

How can I tell if two vectors are perpendicular?

Their dot product is zero. Enter A = (3, 4, 0) and B = (minus 4, 3, 0) and the page shows a dot product of 0 and an angle of 90 degrees. With decimals from measurement, expect a tiny nonzero value instead of exactly zero, and judge it against the product of the two lengths rather than against zero itself.

Why did a small change to Ax move the angle so much?

Changing Ax alters both the dot product and the length of A, and the angle depends on their ratio. Going from 3 to 1.8 cuts the dot product from 12 to 7.2 while |A| only drops from 5 to 4.386, so the cosine falls and the angle opens from 61.315 to 70.835 degrees. Small vectors are more sensitive to one component.

Is the cross product magnitude the same as the sine of the angle?

Only for unit vectors. In general |A × B| is |A| times |B| times sin θ. For the default, 21.932 divided by 25 gives about 0.877, which is the sine of 61.315 degrees. If you want the sine directly, divide the cross magnitude by the product of the two magnitudes shown underneath it.

Can I use this for work done by a force?

Yes. Work is the dot product of the force vector and the displacement vector. Enter the force in newtons as A and the displacement in metres as B, and the dot product is the work in joules. A force at right angles to the motion does no work, which shows up here as a dot product of zero.

What about torque?

Torque is a cross product, r × F, where r runs from the pivot to the point where the force acts. The page gives its magnitude, in newton metres if r is in metres and F in newtons. It does not give the direction of the torque axis, so use the component formula by hand when you need it, keeping r first. Swapping r and F flips the axis but not the magnitude.

How many decimals are reliable for nearly parallel vectors?

The magnitudes and dot product are fine. The angle is the weak point, because it is found with an arccosine, and arccos is very flat near a cosine of 1. For vectors less than about a hundredth of a degree apart, compute atan2 of the cross magnitude and the dot product yourself, which keeps its accuracy at small angles.

Two length 5 vectors at 61.3 degrees

Vector A starts as (3, 4, 0) and vector B as (4, 0, 3). Both have length exactly 5, which is why those entries were chosen: 3, 4, 5 is the familiar right triangle, laid in a different plane for each vector. The calculator reports a dot product of 12, an angle of 61.315 degrees and a cross product magnitude of 21.932, along with the two magnitudes of 5.

Every output is symmetric in A and B. Swap the two vectors and nothing on screen changes. That is true of the dot product, the angle and the magnitudes by definition, and it is true of the cross product magnitude because B × A is just A × B pointing the other way. The sign and direction of the cross product are not shown here, so the order you enter the vectors in does not matter for this page.

The dot product of 12, term by term

The dot product multiplies matching components and adds them. For the default that is 3 × 4 + 4 × 0 + 0 × 3 = 12 + 0 + 0 = 12. Only the x components contribute, because A has nothing in z and B has nothing in y.

Dividing by the two lengths turns it into a cosine. 12 divided by 5 × 5 is 0.48, and the angle whose cosine is 0.48 is 61.315 degrees. That is all the angle line does. A positive dot product always means an angle under 90 degrees, a negative one means over 90, and zero means the vectors are perpendicular.

The dot product also gives you a projection, which the page does not print. The length of A's shadow along B is A·B divided by |B|, here 12/5 = 2.4. As a vector it is (A·B / |B|²) times B, which is 0.48 × (4, 0, 3) = (1.92, 0, 1.44). That is the part of A that points along B; what remains, A minus the projection, is perpendicular to B.

Watch the Lower preset, which changes Ax from 3 to 1.8. The dot product drops to 7.2 because only the x term changes, 1.8 × 4. The length of A also falls, to 4.386, and the angle opens to 70.835 degrees. Raise Ax to 4.5 and the dot product climbs to 18, |A| to 6.021, and the angle narrows to 53.278 degrees.

The cross product components behind 21.932

The page reports only the length of A × B, but the vector itself is easy to write out. Its components are (Ay·Bz minus Az·By, Az·Bx minus Ax·Bz, Ax·By minus Ay·Bx). For the default that is (4 × 3 minus 0, 0 minus 3 × 3, 0 minus 4 × 4) = (12, minus 9, minus 16).

Check that it really is perpendicular to both inputs. A·(A × B) = 36 minus 36 + 0 = 0, and B·(A × B) = 48 + 0 minus 48 = 0. Both zero, as they must be. If you ever compute a cross product and one of these checks fails, a sign has gone wrong, usually in the middle component, which is the one people most often flip.

The length of (12, minus 9, minus 16) is the square root of the sum of the squares, and it comes out at 21.932. That number is also the area of the parallelogram with A and B as two sides. Half of it, 10.966, is the area of the triangle with corners at the origin, the tip of A and the tip of B. Triangle area in 3D is one of the most practical uses of this page.

A consistency check linking all four outputs

The dot and cross products are not independent. The dot product is |A||B|cos θ and the cross magnitude is |A||B|sin θ. Since cos² + sin² = 1, the squares of the two must add to the square of |A||B|.

For the default, 12 squared plus 21.932 squared should equal 25 squared. Run it on a phone calculator and it does, to rounding. The same holds for the presets: with Ax = 4.5, 18 squared plus 24.13 squared lands on the square of 6.021 × 5.

This gives a second way to find the angle: θ = atan2(|A × B|, A·B). For the default that is atan2(21.932, 12), again 61.315 degrees. The atan2 route is the more accurate one when the vectors are nearly parallel. The engine uses the arccos route, clamped so rounding cannot push the cosine past 1. For ordinary inputs the two agree to every displayed decimal, but for vectors a tiny fraction of a degree apart the arccos result can lose precision.

Parallel, opposite and perpendicular vectors

Three special cases are worth running once so you recognise them. Keep A = (3, 4, 0) and set B to (6, 8, 0), a stretched copy of A. The angle is 0, the cross magnitude is 0 and the dot product is 50, which is simply 5 × 10.

Set B to (minus 3, minus 4, 0), pointing the other way. The angle is a straight angle, half a full turn, the cross magnitude is again 0, and the dot product is minus 25. A zero cross product only tells you the vectors lie on one line. You need the sign of the dot product to know whether they point together or apart.

Set B to (minus 4, 3, 0). Now the dot product is 0, the angle is exactly 90 degrees and the cross magnitude is 25, the full product of the two lengths. At right angles the parallelogram becomes a rectangle, so its area is just length times width.

Unit vectors and direction cosines from the magnitude lines

The two magnitude lines are more useful than they look. Divide each component of a vector by its magnitude and you get a unit vector, length 1, pointing the same way. For the default A that is (3/5, 4/5, 0) = (0.6, 0.8, 0), and for B it is (0.8, 0, 0.6).

Those unit components are the direction cosines: the cosines of the angles the vector makes with the x, y and z axes. A makes an angle with the x axis whose cosine is 0.6, about 53 degrees, and it is at right angles to the z axis because its z cosine is 0. The squares of the three direction cosines always add to 1, a quick check on your division.

Once both vectors are unit length, the dot product is the cosine of the angle with no division needed. Here 0.6 × 0.8 + 0.8 × 0 + 0 × 0.6 = 0.48, the same cosine the calculator uses for 61.315 degrees. Normalising first is how most graphics and physics code handles angles, since the unit vectors get reused for other steps.

A word of caution: the page has no normalise button, and the angle and cross magnitude it shows are for the vectors as entered. Scaling A by 10 multiplies the dot product and the cross magnitude by 10 but leaves the angle exactly where it was. If an answer changes when you only rescale a vector, a component was typed wrongly.

Why a zero vector is refused

Enter A = (0, 0, 0) and the page does not return a result. It shows a message saying the angle between vectors is undefined when either vector is zero, and asks for at least one nonzero component in each. The same happens with B = (0, 0, 0).

That is the right call. A zero vector has no direction, so there is no angle between it and anything. The cosine formula would divide by zero. The dot product and the cross magnitude are perfectly well defined, both 0, but an angle on the same screen would be meaningless, so the whole result is held back.

If you need the dot or cross product with a zero vector, you already know the answer: both are 0. If the message appears when you did not mean to enter a zero vector, check for a vector built from two identical points. Q minus P is zero when P and Q are the same, and that is the usual way it happens in practice.

Code that loops over many vectors, such as surface normals in a 3D model, should copy this behaviour. A degenerate triangle has a zero normal, and a routine that quietly reported an angle of 0 would make it look perfectly aligned with the light or the camera. Test the magnitude first and skip or flag the zero case.

Getting coordinates in the right order

Each vector takes three fields, x then y then z. The most common slip is entering two points instead of a vector. If your vector runs from point P to point Q, its components are Q minus P, not the coordinates of Q. For a triangle with corners P, Q and R, enter Q minus P as A and R minus P as B, and half the cross magnitude is the triangle's area.

The second slip is units. The angle comes out in degrees. If a later formula needs radians, multiply by π and divide by the number of degrees in a half turn; 61.315 degrees is about 1.07 radians. The dot and cross magnitudes carry the product of whatever units your components use, so for two displacement vectors in metres the cross magnitude is an area in square metres.

Two dimensional problems work too. Put zero in both z fields. The cross product then points straight along z, and its magnitude equals the absolute value of Ax·By minus Ay·Bx, the 2D cross product used for orientation tests.