Inner and Cross Products

by William Shoaff with lots of help


Contents

Inner Products

Inner products define a geometry on a vector space: distances and angles. Let

\begin{displaymath}\vec{v} = \langle v_x,\,v_y,\,v_z\rangle\quad\mbox{and}\quad \vec{u} = \langle u_x,\,u_y,\,u_z\rangle\end{displaymath}

be two three dimensional vectors in $\mathbb{R} ^3$. Their inner (dot or scalar) product is the real number

\begin{displaymath}\langle \vec{v} \vert \vec{u}\rangle=v_xu_x+v_yu_y+v_zu_z.\end{displaymath}

For example, pretend

\begin{displaymath}\vec{v} = \langle 3,\,1,\,4\rangle\quad\mbox{and}\quad \vec{u} = \langle 5,\,-7,\,7\rangle.\end{displaymath}

Then

\begin{displaymath}\langle \vec{v} \vert \vec{u}\rangle=3\cdot5+1\cdot(-7)+4\cdot 7 = 36.\end{displaymath}

The inner product of a vector with itself is the square of its length:

\begin{displaymath}\langle \vec{v} \vert \vec{v}\rangle=v_xv_x+v_yv_y+v_zv_z=\Vert\vec{v}\Vert^2.\end{displaymath}

The length of the specific vector $\vec{v}$ above is

\begin{displaymath}\sqrt{\langle \vec{v} \vert \vec{v}\rangle}=\sqrt{3\cdot3+1\cdot1+4\cdot 4} = \sqrt{26}.\end{displaymath}

The cosine of the angle $\theta$ between two vectors $\vec{v}$ and $\vec{u}$is the inner product of the vectors divided by their lengths:

\begin{displaymath}\cos(\theta) = \frac{\langle \vec{v} \vert \vec{u}\rangle}{\Vert\vec{v}\Vert\Vert\vec{u}\Vert}.\end{displaymath}

Cosines will occur in illumination models and we will compute them using inner products. In these instances we'll usually want to work with vectors that have length 1 (unit vectors). The angle between the specific vectors $\vec{v}$ and $\vec{u}$ above is

\begin{displaymath}\arccos\left(\frac{36}{\sqrt{26}\sqrt{123}}\approx 50.46^{\circ}\right).\end{displaymath}

Two vectors are orthogonal (perpendicular or at right angles) when their inner product is zero:

\begin{displaymath}\langle \vec{v} \vert \vec{u}\rangle = 0 \Rightarrow \vec{v} \mbox{and} \vec{u}
\mbox{are orthogonal}.\end{displaymath}

Testing for orthogonality will be important in many algorithms

Cross Products

The cross product of two three dimensional vector is another vector.


\begin{displaymath}\vec{v} \times \vec{u} = (v_yu_z - v_zu_y,\, v_zu_x - v_xu_z,\, v_xu_y-v_yu_x).\end{displaymath}

One way to remember this result is by setting it up as a $3\times 3$determinant.

\begin{displaymath}\vec{v} \times \vec{u} = \left\vert\begin{array}{ccc}
i & j ...
...v_x & v_y & v_z \\
u_x & u_y & u_z \\ \end{array}\right\vert,\end{displaymath}

where i, j, k are place holders for the x, y, and z coordinates of the cross product vector (ask the physicists why they use i, j and k). Note that order matters (cross products are not commutative)

\begin{displaymath}\vec{v} \times \vec{u} = - (\vec{v} \times \vec{u}).\end{displaymath}

The cross product $\vec{v} \times \vec{u}$ is orthogonal to both $\vec{v}$ and $\vec{u}$, that is

\begin{displaymath}\langle \vec{v} \times \vec{u})\vert \vec{v} \rangle = \langle \vec{v} \times
\vec{u})\vert \vec{u} \rangle = 0.\end{displaymath}

Can you show this? We often use compute cross product to deliver us a vector perpendicular to two given vectors.

The lenght of the cross product is:

\begin{displaymath}\Vert\vec{v}\times \vec{u}\Vert = \Vert\vec{v}\Vert\Vert vec{u}\Vert\sin(\theta),\end{displaymath}

where $\theta$ is the angle between $\vec{v}$ and $\vec{u}$.

Triple Scalar Products

Do you recall this one as well? It may not be as widely useful in graphics, but the absolute value of a triple scalar product gives the volume of the parallelpiped spanned by three vectors $\vec{v}$, $\vec{u}$, and $\vec{w}$. That is,

\begin{displaymath}\vert\langle \vec{v} \vert (\vec{u} \times \vec{w}) \rangle\vert\end{displaymath}

is the volume of the box formed by the three vectors.

Matrix Products

Knowing how to compute the product of matrices is extremely important for computer graphics. Here's a small example. Let

\begin{displaymath}A= \left[\begin{array}{cc}
a_{11} & a_{12} \\
a_{21} & a_{22} \\ \end{array}\right]\end{displaymath}

and

\begin{displaymath}B= \left[\begin{array}{cc}
b_{11} & b_{12} \\
b_{21} & b_{22} \\ \end{array}\right].\end{displaymath}

Then the matrix product AB is

\begin{displaymath}AB = \left[\begin{array}{cc}
a_{11}b_{11}+a_{12}b_{21} & a_{...
...a_{22}b_{21} & a_{21}b_{12}+a_{22}b_{22} \\ \end{array}\right].\end{displaymath}

In general, the element in row i, column j of the product AB is the inner product of row i of matrix A with column j of B.

Notice that matrices must be ``conformal'' to be multiplied, that is, the number of columns of A must be the number of rows of B. Also, note that matrix multiplication is not commutative.

Other sources

Got a math question? Here's a good site where you might find an answer.

http://www.astro.virginia.edu/~eww6n/math/math0.html.



William Shoaff
2000-09-08