cross
Cross product of two 3-element vectors.
Category: Mathematics > Linear Algebra
Syntax
C = cross(A, B)
Returns the vector A x B, perpendicular to both.
Description
The cross product is perpendicular to both inputs, follows the right-hand rule, and has length equal to the area of the parallelogram they span. It is zero when the vectors are parallel, and cross(B, A) = -cross(A, B).
In MATLAB, cross also accepts arrays of 3-vectors and a dimension argument.
Input arguments
A, B- Vectors with three elements each.
Output arguments
C- Vector with the components
[A2*B3 - A3*B2, A3*B1 - A1*B3, A1*B2 - A2*B1].
Example
Unit vectors and a general pair
cross([1 0 0], [0 1 0])
cross([1 2 3], [4 5 6])
Output
ans = 1×3
0 0 1
ans = 1×3
-3 6 -3