Maths - Vector Cross Product

When we looked at vectors we saw that they must have two operations addition and scalar multiplication.

operation notation explanation
addition V(a+b) = V(a) + V(b) the addition of two vectors is done by adding the corresponding elements of the two vectors.
scalar multiplication V(s*a) = s * V(a) a scalar product of a vector is done by multiplying the scalar product with each of its terms individually.

These operations interact according to the distributivity property: s*(b+c)=s*b+s*c

In addition to these operations we can have other operations which we can apply to vectors such as the vector cross product:

Vector Cross Product

Unlike the scalar product, both the two operands and the result of the cross product are vectors.

The vector cross product has some useful properties, it produces a vector which is mutually perpendicular to the two vectors being multiplied.

vector cross product

The resulting vector A × B is defined by:

x = Ay * Bz - By * Az
y = Az * Bx - Bz * Ax
z = Ax * By - Bx * Ay

where x,y and z are the components of A x B

The scalar length of A×B is,

|A × B| = |A| * |B| * sin(θ)

where θ is the angle between A and B.

The cross product interpretation only to 3D vectors. For instance in 2 dimensions it is not possible to find another vector which is mutually perpendicular to 2 arbitrary vectors, in 4 dimensions (or greater) there are many vectors which are mutually perpendicular to 2 arbitrary vectors.

The cross product can be used to calculate the Normal to a surface as shown here.


In the above diagram it is is difficult to draw the directions to clearly represent all 3 dimensions. So I thought it would help check the direction by working out an example using approximate direction:

If we let:

Vector A be in the y direction (Ax=0 , Ay=1 , Az = 0)
Vector B be in the x direction (Bx=1 , By=0 , Bz = 0)

so, Vector A×B components:

x = Ay * Bz - By * Az = 0
y = Az * Bx - Bz * Ax = 0
z = Ax * By - Bx * Ay = -1


AxB = (0 , 0 , -1) = away from viewer

The cross product is also given by the determinant:

i j k
Ax Ay Az
Bx By Bz

where: i,j & k are unit vectors in the x,y and z dimensions.

Important Issues

We must be careful, when doing vector algebra with cross multiplication, because we can't use the usual rules:


A×B + B×A = 0 anti-commutative, vector cross multiplication is not commutative, changing the order reverses the direction of the resulting vector: A×B = - B×A.
A×(B×C) +
B ×(C×A) +
C ×(A×B) = 0

Jacobi identity : anti-associative : anti-symmetry
So cross multipication is not associative.

A × A = 0 A 'squared' is a zero length vector because sin(0) = 0
A × (B + C) = (A × B) + (A × C) cross multiplication for vectors is distributive over +
0 × A = 0  


For example, the following expression:

A × A × B

We might expect that this is zero, because A x A = 0, but this is not necessarily so because cross multiplication is not associative. We need to specify the order, if it is:

A × (A × B)

then the result is not necessarily zero.

Related Multiplications

There are generalisations to vector algebra, for example,

Clifford Algebra In particular the exterior product of Grassmann algebra which is incorporated into Clifford algebra.
Lie Algebra Lie algebra is a linerasation of Lie groups and therefore relates this topic to groups and symmetries.

The Grassmann exterior product has much nicer properties than the cross product:

Comparison to Exterior Product

The exterior product combines two vectors and produces a bivector. In three dimensions the bivector has similar properties to a vector and so, for many purposes, can be treated as a vector. For instance the multiplication table for the cross product is:

b.e1 b.e2 b.e3
a.e1 0 e3 -e2
a.e2 -e3 0 e1
a.e3 e2 -e1 0

The exterior multiplication table is:

b.e1 b.e2 b.e3
a.e1 0 e1/\e2 -e3/\e1
a.e2 -e1/\e2 0 e2/\e3
a.e3 e3/\e1 -e2/\e3 0

So the result of the two types of multiplication is virtually the same, the difference is that the exterior multiplication produces a bivector and not a vector. The important thing is that multiplication table of a vector /\ bivector is not the same as vector /\ vector, in fact the multiplication table of vector /\ bivector is like the dot product of vector • vector.

So when we have triple multiplications, they are associative, the exterior product of 3 vectors, A, B and C gives the volume enclosed by the three vectors:

A /\ B /\ C

This is equivalent to this equation of cross and dot products:

(A × B) • C

Duality between vectors and bivectors in 3 dimensions

This duality only applies to three dimensions, if two 2-dimentional vectors are cross multiplied the bivector is one dimensional, if two 4-dimentional vectors are cross multiplied the bivector is 6-dimentional. bivectors are discussed here.

In three dimensional vector algebra only, a bivector also has three dimensions, so for most purposes (in three dimensions) we can treat the result of a cross product as a vector.

Skew Symmetric Matrix

We can also work out a 3x3 skew symmetric matrix which is equivalent to the cross product, in other words, if,

C = A × B

Then we can find a skew symmetric matrix [~A] such that:

C = [~A] B

This matrix is:

[~A] =
0 -Az Ay
Az 0 -Ax
-Ay Ax 0

As described here.


The following is Java code for vector cross product.

Void cross(sfvec3f other) {
   double xh = y * other.z - other.y * z;
   double yh = z * other.x - other.z * x;
   double zh = x * other.y - other.x * y;
   x = xh;
   y = yh;
   z = zh;

The following is managed C++ code for vector cross product.

Void sfvec3f::cross(sfvec3f* other) {
   double xh = y * other->z - other->y * z;
   double yh = z * other->x - other->z * x;
   double zh = x * other->y - other->x * y;
   x = xh;
   y = yh;
   z = zh;

This method will be used by the sfvec3f class.

Further Reading

Vectors can be manipulated by matrices, for example translated, rotated, scaled, reflected.

There are mathematical objects known a multivectors, these can be used to do many of the jobs that vectors do, but they don't have some of the limitations (for example vector cross product is limited to 3 dimensions and does not have an inverse).

metadata block
see also:


Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Introduction to 3D Game Programming with DirectX 9.0 - This is quite a small book but it has good concise information with subjects like, maths introduction and picking.

cover If you are interested in 3D games, this looks like a good book to have on the shelf. If, like me, you want to have know the theory and how it is derived then there is a lot for you here. Including - Graphics pipeline, scenegraph, picking, collision detection, bezier curves, surfaces, key frame animation, level of detail, terrain, quadtrees & octtrees, special effects, numerical methods. Includes CDROM with code.

This book contains more mathematically rigorous methods for picking than described above.

Other Math Books

Terminology and Notation

Specific to this page here:


This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.