Cross Product

The formula for the cross product of two vectors A & B is:

  [ ( Ay Bz - Az By ),   ( Az Bx - Ax Bz ),   ( Ax By - Ay Bx ) ]


The Python equivalent is:

def crossProduct(A,B):
    return [ A[1] * B[2] - A[2] * B[1],
             A[2] * B[0] - A[0] * B[2],
             A[0] * B[1] - A[1] * B[0] ]

The direction of the cross product is determined by the right-hand rule applied from vector A to vector B (so if you multiply them in the reverse order, the result will point the opposite direction).