## Vector expressions as matrices, using outer products

Reading through Peter Shirley’s graphics blog I found an old post asking about what the outer product means operationally and what value it may have in graphics. This is actually a pretty interesting topic, and I thought I’d try to explain what the outer product means to me and the value I see it having.

So, first we have the *inner product* (which everyone knows in term of the *dot product*):

Then there is the perhaps less familiar *outer product* (**not** to be confused with the *cross product*) which looks like so:

Just by playing around a little with pen and paper, experimenting with the simplest possible inner and outer product expressions, you might notice that

Because it is always better to work coordinate-free, we drop the coordinates and express this just in terms of the *column* vectors **a**, **b**, and **c** giving (**a**^{T}**b**)**c**^{T} = **a**^{T}(**b****c**^{T}) or, using dot products, (**a**⋅**b**)**c** = **a**^{T}(**b****c**^{T}). What this means is that whenever we scale a vector (**c**) with the result of a dot product (**a**⋅**b**), we could as well be expressing this as a vector (**a**) multiplied by the outer product of the other two vectors (**b****c**^{T}).

To see how this can be useful, let’s consider the problem of reflecting a point Q about a plane defined by a unit normal **n** and a point P on the plane. Some straightforward vector math has it that the new point is given by Q’ = Q – 2((Q – P)⋅**n**)**n**. To make things really simple, let’s start with the plane going through the origin, so P = (0, 0, 0), for which the expression becomes Q’ = Q – 2(Q⋅**n**)**n**.

Rewriting this expression using the outer product identity above results in Q’ = Q – 2(Q⋅**n**)**n** = Q – 2Q(**n****n**^{T}). This can be further simplified by noting that Q = **I**Q, where **I** is the identity matrix, giving: Q’ = **I**Q – 2Q(**n****n**^{T}) = (**I** – 2(**n****n**^{T}))Q. We can set **M** = (**I** – 2(**n****n**^{T})) and note that Q’ = **M**Q is now a *matrix transform* to perform the reflection of Q and that there are no vectors anywhere. That is, outer products (along with the skew-symmetric matrix form of the cross product) allow us to turn vector expressions into matrix expressions!

If P is not the origin, the matrix expression instead becomes:

Q’ =

= Q – 2((Q – P)⋅**n**)**n**

= Q – 2(Q – P)(**n****n**^{T})

= **I**Q – 2Q(**n****n**^{T}) + 2P(**n****n**^{T})

= (**I** – 2(**n****n**^{T}))Q + 2P(**n****n**^{T})

= **M**Q + **t**

The matrix **M** and the translation **t** can be put into a single 4×4 matrix **N** as **N** = [**M** **t**; 0 1]. We can now use **N** to reflect points in their homogeneous form, [Q_{x} Q_{y} Q_{z} 1]^{T}, about the plane that was given by **n** and P.

Finally, it may be worth noting that if we drop the constant factor 2 from the expressions above, we have a transformation that projects all points into the plane given by **n** and P. (Some might recall that such transforms, along with a skew, was once used to create cheesy drop shadows from objects.)

### Similar Posts:

- None Found
- My recommended books