VECDOT

Purpose:

Computes the vector dot product.

Syntax:

VECDOT(a, b, dim)

(vdot, vang) = VECDOT(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.

0

:

data dependent (default)

1

:

calculate column-wise

2

:

calculate row-wise

Returns:

A scalar or series, the dot product of each vector.

 

(vdot, vang) = VECDOT(a, b, dim) returns the dot product and angle in radians between each vector.

Example:

u = {2, -1,  3};

v = {5,  3, -1};

d = vecdot(u, v);

 

d == 4

 

d is the dot product of vector u and v.

Example:

u = {2, -1,  3};

v = {5,  3, -1};

(d, a) = vecdot(u, v);

 

d == 4

a == 1.389097

 

d is the dot product of vector u and v, and a is angle between the vectors in radians (79.589372 degrees).

Example:

u = {2, -1,  3};

v = {3,  3, -1};

(d, a) = vecdot(u, v);

 

d == 0

a == 1.570796

 

d is the dot product of vector u and v, and a is angle between the vectors in radians (90 degrees) showing that u and v are perpendicular.

Example:

W1: {{2, -1, 3},

     {3,  3, 2},

     {1,  2, 4}}

 

W2: {{3,  1, 3},

     {2,  3, 1},

     {1, -2, 2}}

 

W3: vecdot(w1, w2)

 

W3 == {14, 17, 5}

 

W3 contains the dot product of W1 and W2 where each row is considered a vector with X, Y, Z coordinates.

Example:

W1: {{2, -1, 3},

     {3,  3, 2},

     {1,  2, 4}}

 

W2: {{3,  1, 3},

     {2,  3, 1},

     {1, -2, 2}}

 

W3: vecdot(w1, w2, 1)

 

W3 == {{13, 4, 19}}

 

W3 contains the dot product of W1 and W2 where each column is considered a vector with X, Y, Z coordinates.

Example:

W1: {{2, -1, 3},

     {3,  3, 2},

     {1,  2, 4}}

 

W2: vecdot(w1, w1)

W3: vecdot(w1, w1, 1)

W4: rowsum(w1 * w1)

W5: colsum(w1 * w1)

 

W2 == W4 == {14, 22, 21}

W3 == W5 == {{14, 14, 29}}

 

W2 and W4 compute the magnitude squared of the vectors row-wise.

 

W3 and W5 compute the magnitude squared of the vectors colunm-wise.

Example:

W1: {{2, -1, 3},

     {3,  3, 2},

     {1,  2, 4}}

 

W2: {{3,  1, 3},

     {2,  3, 1},

     {1, -2, 2}}

 

W3: (d, a) = vecdot(w1, w2);ravel(d, a)

 

W3 ==  {{14.0, 0.539},

        {17.0, 0.251},

        { 5.0, 1.199}}

 

where the first column of W1 is the dot product and the second column is the angle.

Example:

u = xyz({{2, -1, 3}, {3,  3, 2}, {1,  2, 4}});

v = xyz({{3, 1, 3},  {2, 3, 1},  {1, -2, 2}});

(d, a) = vecdot(u, v);

 

d == {14, 17, 5}

a == {0.539, 0.251, 1.199}

 

Same as above except the vectors are in XYZ form and the result is returned in two separate variables.

Remarks:

The dot product of two vectors a and b can be computed with:

 

vecdot

 

Note that:

 

mag2

 

is the magnitude squared of the vector.

 

For two Euclidean vectors, the dot product becomes:

 

vecdot

 

where ||a|| and ||b|| are the magnitudes of a and b and θ is the angle between a and b.

 

Thus, the angle θ between two Euclidean vectors a and b is:

 

angle

 

For vectors a and b associated with the columns of a matrix:

 

vecdot

 

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.

 

VECDOT handles XY and XYZ series as vector inputs.

 

See VECCROSS  to compute the vector cross product.

See Also:

NORM

SUM

VECCROSS