VectorCross


Two vectors that don't have the same direction1 will form a plane. VectorCross() returns a vector which is perpendicular to this plane. The length of the cross product is the sine of the angle between the vectors multiplied by their lengths (see the math below). Syntax:

crossvec=VectorCross(vector1, vector2);


The Right-Hand Rule
There are two directions that are perpendicular to a plane - right and left. The right hand rule determines which direction the cross product will have.

The direction of the cross product is determined by placing vector1 and vector2 tail-to-tail, flattening the right hand, extending it in the direction of vector1, and then curling the fingers in the direction that the angle vector1 makes with vector2. The thumb then points in the direction of the cross product.


The Math
crossvec=(y1*z2 - y2*z1, x2*z1 - x1*z2, x1*y2 - x2*y1);

The formula for the length of the cross product is: sinθ * |v1| * |v2|.
Where θ is the angle between the vectors.
And |v1| is the length of vector1.
And |v2| is the length of vector2.


Geometrical Application
The green vector is the cross product of the red and blue vectors. Because the sine of 90 degrees is 1 and the red and blue vectors have a length of one, the length of the cross product is one.

The right hand rule shows that the vector points upwards on the z axis and not in the negative direction.


1That is, the two vectors are not colinear. If they are, there will be no angle between them and the cross product will be the zero vector.