Engineering Math - Matrix

 

 

 

Vector - Cross Product

 

It is pretty complicated process to calculate the cross product in terms of calculation process, but it is not that complicated to understand the geomatrical meaning for it. (Fortunately you don't have to calculate this by your hand. A lot of sotware package out there would do this for you. So what you have to do is just to understand the concept).

The cross product takes two 3D vectors and returns a third vector that is perpendicular to both of them. I'll start with its geometric meaning and the formula based on the angle. Then we'll calculate it with a determinant, first for two vectors on the x-y plane and then for any two 3D vectors. The last sections list its algebraic properties and show where engineers use it.

What does the cross product mean geometrically ?

First thing you remember about the cross product is that the result of cross product of two vectors is also a vector (you would remember the result of inner product of two vectors is a scalar). By the definition of vector, it has both direction and size(magnitude).

Then, what is the direction of the resulting vector of cross product ?

It is normal (perpendicular) to the plane on which the two vectors sits on. It implies that if you get the cross product of two vector, you will get a vector which is normal to the two input vectors. This is one of the reason why 'cross product' is such a useful tool.

Then, what is the size(magnitude) of the resulting vector of cross product ?

It is the area of the area surrounde by the two vectors.

Following is the illustration showing what I described above.

 

Cross product w of vectors u and v, perpendicular to their plane with length equal to the area A

The cross product w = u x v stands perpendicular to the plane of u and v. Its length equals the area A of the parallelogram that u and v span.

The area in the figure is the area of the parallelogram with sides u and v, not of the triangle between them. The triangle has half of that area. The direction also has a sign. The cross product follows the right-hand rule: point the fingers of your right hand along u and curl them toward v, and your thumb gives the direction of u x v. So swapping u and v turns the result upside down.

  • The result is a vector : unlike the inner product, which gives a scalar, the cross product gives a vector with a size and a direction.
  • The size is |u||v|sin(θ) : it is largest when u and v are perpendicular, and it is zero when they are parallel.
  • The direction follows the right-hand rule : u x v and v x u point in opposite directions.

How is the cross product written as a formula ?

Following is the concept of Cross Product represented in mathematical formula. The calculation shown in equation (2) may look pretty simple, but if the vectors are not on the x-y plane the calculation gets more complicated. But as I said, don't worry about this. Software would do it for you.

 

 

 

If you think of the meaning of the equation and illustration shown above, if both the vector u and v are on x-y plane, the resulting cross product vector is always in parallel with z axis.  

Equation (1) builds the result from lengths and an angle, and n is the unit vector perpendicular to the plane, chosen by the right-hand rule. Equation (2) is the same vector for u and v on the x-y plane. In equation (2), read n as the unit vector along the z axis. Then the sign of x1y2 - x2y1 tells you whether the result points along +z or along -z.

Let's check the two equations with numbers. Take u = (3, 1) and v = (1, 2). Equation (2) gives 3 x 2 - 1 x 1 = 5, so u x v = 5k. For equation (1), |u| = √10, |v| = √5, and the angle between them is 45 degrees. So |u||v|sin(θ) = √50 x 0.7071 = 5, which matches. The parallelogram spanned by u and v therefore has an area of 5.

  • Equation (1) needs the angle : it shows the meaning, but you must find θ first.
  • Equation (2) needs only the coordinates : it gives the same vector without any angle.
  • The sign in equation (2) carries the direction : a negative value means the result points along -z.

How is the cross product calculated with a determinant ?

There is another way of calculating the cross product of the two vectors  u and v from a determinant equation as shown below. The determinant form avoids the angle in equation (1). It also extends directly to vectors that are not on the x-y plane, as the next section shows.

Since the vector u and v is on x-y plan, you can represent these two vector as a three dimensional vector as shown below. (Why we need to make these vector as a three dimensional form ? It is because the cross product of the two vectors require at least three dimensional space.  It is because the resulting vector from cross product is perpendicular to the vectors given for the cross product. That is, the resulting vector of "u x v" is perpendicular to v and u. Even though you can represent u and v in 2 D plan, you need 3D space to represent u and v and 'cross product' all together.

 

 

Now let's define three additional unit vector sitting along each of 3D axis as shown below.

 

 

Once you have all the vectors described above, the cross product of the two vector u and v can be defined as a matrix determinant as shown below.

 

 

Now the remaining thing is just to calculate the determinant of 3x3 matrix. You can calculate the determinant of this matrix as shown below.

 

     

     

 

You may think that I am intentionally complicate a simple thing. At first look, it would look too complicated in terms of calculation but this one has an advantage.  If you want to calculate the cross product using the equation at the beginning of this page, you need to figure out angle between the two vectors. However, figuring out the angles between the two vectors is not easy (you would need to do Inner Product of the two vectors in order to figure out the angle between the two vectors). However, if you use calculate the cross product in this way (i.e, using the determinant), you don't have to worry about figuring out the angle between the two vectors.

The diagonal pattern in the determinant image is the rule of Sarrus. You copy the first two rows below the matrix, add the three products along the blue diagonals and subtract the three products along the red diagonals. This shortcut works only for a 3 x 3 determinant. For the x-y plane case, every term that contains a 0 disappears, and only the k term x1y2 - y1x2 is left. That is the same result as equation (2).

  • The first row holds the unit vectors : i, j and k are not numbers, so the determinant here is a memory aid that expands into a vector.
  • The rule of Sarrus is only for 3 x 3 : a larger determinant needs cofactor expansion instead.
  • No angle is needed : the determinant uses only the coordinates of u and v.

How is the cross product of two general 3D vectors calculated ?

Also using this way, you can get the cross product of two vectors in 3D space pointing two any direction (meaning the two vector u and v need not to be on x-y plane). You can represent any arbitrary two vector u, v and reference vector i, j, k as follows.

 

 

Using the same method shown above (described in more detail in Determinant page), you can calculate the cross product as shown below.

 

 

 

Let's try the general formula on u = (1, 2, 3) and v = (4, 5, 6). The three components are calculated below. You can check the result with the inner product. A vector perpendicular to both u and v must give zero inner product with each of them, and it does.

u x v = ( y1*z2 - z1*y2 ,  z1*x2 - x1*z2 ,  x1*y2 - y1*x2 )
      = ( 2*6 - 3*5   ,  3*4 - 1*6     ,  1*5 - 2*4     )
      = ( -3 , 6 , -3 )

u . (u x v) = 1*(-3) + 2*6 + 3*(-3) = 0
v . (u x v) = 4*(-3) + 5*6 + 6*(-3) = 0
|u x v|     = sqrt(9 + 36 + 9)      = sqrt(54) = 7.35
  • Each component leaves out its own axis : the i component uses only y and z, the j component uses z and x, and the k component uses x and y.
  • The x-y plane case is a special case : with z1 = z2 = 0, the i and j components vanish and the general formula reduces to equation (2).
  • Check a result with the inner product : u x v must be perpendicular to both u and v.

What algebraic properties does the cross product have ?

The cross product does not follow all the rules of ordinary multiplication, and the differences cause most of the mistakes. The list below gives the rules you'll use when you simplify an expression. Each rule follows from the determinant form in the previous sections.

  • It is anti-commutative : v x u = -(u x v). For the example above, v x u = (3, -6, 3).
  • A vector crossed with itself gives zero : u x u = 0, and more generally u x v = 0 whenever u and v are parallel.
  • It distributes over addition : u x (v + w) = u x v + u x w, and a scalar factor moves out, so (cu) x v = c(u x v).
  • It is not associative : (i x i) x j = 0, but i x (i x j) = i x k = -j. So the brackets in a double cross product matter.
  • The unit vectors form a cycle : i x j = k, j x k = i and k x i = j. Going around the cycle backwards gives the negative, for example j x i = -k.
  • The length links to the inner product : |u x v|2 = |u|2|v|2 - (u . v)2. For the example above, 14 x 77 - 322 = 54, which matches |u x v|2.

The last rule is useful because it connects the two products. The inner product gives |u||v|cos(θ), and the cross product gives |u||v|sin(θ). Together they satisfy cos2(θ) + sin2(θ) = 1. See Inner Product for the other half of this pair.

Where is the cross product used ?

The cross product appears wherever a problem needs a direction perpendicular to two given directions, or an area spanned by two vectors. Here are the common cases, followed by the functions that compute it in software. The software functions matter, because hand calculation of the six terms is where errors usually enter.

  • Normal vector of a plane : for three points P, Q and R, the vector (Q - P) x (R - P) is perpendicular to the plane through them. Computer graphics uses this to find the surface normal of each triangle.
  • Area of a triangle : the triangle PQR has area |(Q - P) x (R - P)| / 2, half of the parallelogram that the two edge vectors span.
  • Torque and angular momentum : torque is r x F, and angular momentum is r x p, where r is the position vector.
  • Electromagnetics : the magnetic force on a moving charge is qv x B, and the Poynting vector E x H gives the direction and density of the power flow of an electromagnetic wave. So the power from an antenna flows perpendicular to both its E field and its H field.

In Matlab, cross(u,v) returns the cross product of two 3-element vectors. In Python, numpy provides np.cross(u, v). For u = (1, 2, 3) and v = (4, 5, 6), both return (-3, 6, -3), the result calculated above. The numpy function also accepts two 2-element vectors and then returns only the z value, but NumPy 2.0 marks that form as deprecated. So pass 3-element vectors with z = 0 instead, as this page does for the x-y plane case.