Computes the vector cross product.
VECCROSS(a, b, dim)
a |
- |
A series, an XY or an XYZ series. |
|||||||||
b |
- |
A series, an XY or an XYZ series. |
|||||||||
dim |
- |
Optional. An integer or string, the computation dimension.
|
A series, the coordinates of one or more a vectors that are perpendicular to the input vectors.
u = {3, -3, 1};
v = {4, 9, 1};
c = veccross(u, v);
c == {-12,
-1,
39}
The input and output coordinates are column-wise.
To verify that vector C is perpendicular to both U and V:
d1 = vecdot(c, u);
d2 = vecdot(c, v);
d1 == d2 == 0.0.
u = {{3, -3, 1}};
v = {{4, 9, 1}};
c = veccross(u, v);
c == {{-12, -1, 39}}
Same as above except the coordinates are row-wise.
W1: ravel(1..9, 3)
W2: ravel(3..11, 3)
W3: veccross(w1, w2)
W4: veccross(w1, w2, 2)
W3 == {{-6, 12, -6},
{-6, 12, -6},
{-6, 12, -6}}
W4 == {{-6, 12, -6},
{-6, 12, -6},
{-6, 12, -6}}
Both inputs are 3x3 arrays. Both cross products are computed with the coordinates going row-wise.
W1: ravel(1..9, 3)
W2: ravel(3..11, 3)
W3: veccross(w1, w2, 1)
W3 == {{-2, -2, -2},
{ 4, 4, 4},
{-2, -2, -2}}
Same as above except the coordinates go column-wise.
The cross product of two vectors a and b is defined as:
where:
θ is the angle between a and b in the plane that contains them.
||a|| and ||b|| are the magnitudes of a and b.
n is the unit vector perpendicular to the plane that contains a and b.
The cross product of two 3x1 vectors a and b can be computed with:
a x b = {a[2]*b[3] - a[3] * b[2],
a[1]*b[3] - a[3] * b[1],
a[1]*b[2] - a[2] * b[1]}
The dim parameter determines the direction of the coordinates.
dim == 0, data dependent
dim == 1, column-wise
dim == 2, row-wise
For dim == 0, if the number of columns is 3, the coordinates are row-wise (i, j, k), otherwise the coordinates are column-wise.
VECCROSS handles XY and XYZ series as vector inputs.
See VECDOT to compute the vector cross product.