Function cross

Calculate the cross product for two vectors in three dimensional space. The cross product of A = [a1, a2, a3] and B =[b1, b2, b3] is defined as:

cross(A, B) = [ a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1 * b2 - a2 * b1 ]

Syntax

cross(x, y)

Parameters

Parameter Type Description
x Array | Matrix First vector
y Array | Matrix Second vector

Returns

Type Description
Array | Matrix Returns the cross product of x and y

Examples

cross([1, 1, 0],  [0, 1, 1]);  // Returns [1, -1, 1]
cross([3, -3, 1], [4, 9, 2]);  // Returns [-15, -2, 39]
cross([2, 3, 4],  [5, 6, 7]);  // Returns [-3, 6, -3]

See also

dot, multiply