Tuesday, 14 May 2019

Visualizing linear algebra: Cross product

Figure 1: The red arrow is the cross product of
the purple and orange arrows
This is Part 6 in a series on linear algebra [1].

As described in the post on matrices, a 2x2 matrix encodes two column vectors that show where the two unit vectors (i-hat and j-hat) end up when the 2D vector space is transformed. The post on the determinant shows how the unit square defined by those unit vectors is transformed into a parallelogram. The determinant is a measure of the area of the parallelogram which can be negative if i-hat ends up on the left of j-hat, thus indicating the area was flipped, or zero if i-hat and j-hat end up on the same line.

The 3D cross product of two vectors is a third vector that is perpendicular to both and has a length that is their determinant (i.e., the directional area of the parallelogram defined by those vectors) as illustrated in Figure 1. [2]

Figure 2: Solve for vector p
Figure 2 shows the equation for computing a vector p that is the cross product of vectors v and w.

Algebraically, the equation asks what is the vector p such that the dot product of p and a vector [x;y;z] equals the determinant of a 3x3 matrix with column vectors [x;y;z], v and w?

Geometrically, the equation asks what is the vector p such that projecting vector [x;y;z] onto its number line and scaling by the length of p will equal the signed volume of a parallelepiped defined by the vectors [x;y;z], v and w?

The equation can be reorganized as:

p1.x + p2.y + p3.z = x(v2.w3 - v3.w2) +
                     y(v3.w1 - v1.w3) +
                     z(v1.w2 - v2.w1)

The constants on the right hand side are particular combinations of the coordinates of v and w which will be the coordinates of p and thus the cross product of v and w:

            [v2.w3 - v3.w2]
p = v x w = [v3.w1 - v1.w3]
            [v1.w2 - v2.w1]

Figure 3 illustrates that the way the linear transformation works on a given vector [x;y;z] (the white arrow) is to project that vector onto a line p (the red arrow) that's perpendicular to both v and w and then to scale that projection by the area of the parallelogram spanned by v and w. This is the same thing as taking a dot product between [x;y;z] and a vector that's perpendicular to v and w with a length equal to the area of that parallelogram.

Next up: change of basis

--

[1] The figures and examples of the posts in this series are based on the Essence of Linear Algebra series by 3Blue1Brown.

[2] The cross product is used in a 3D vector space where the third vector is computed from the first two. If used in 2D space, it would return a vector that was perpendicular to that 2D space.

No comments:

Post a Comment