Dot Product as Projection

The linear algebraic definition of a dot product is clearly taught everywhere. Namely, the sum of pairwise products between first, second, third values etc. However, one of the more important underlying geometric meanings of the dot product is sometimes neglected. Not here. Much of what we do in computer graphics depends critically upon a reflexive understanding of the dot product as a projection operator. To better understand what we mean by 'projection', read on.

Ross Beveridge

August 28, 2018

As will be common in these notebooks, the next sequence of commands configure options for running the notebook such as how to display math, etc.

In [1]:
%display latex
latex.matrix_delimiters(left='|', right='|')
latex.vector_delimiters(left='[', right=']')

To begin, here are the basics starting with two vectors.

In [2]:
var('a','b','c','d')
u = vector([a,b])
v = vector([c,d])
pretty_print("u = ", u, ",  v = ", v)
pretty_print(LatexExpr("u \cdot v = ") + v.dot_product(u))

If the vector u is of unit length, and the vector v represents the position of a point Q in space, then the dot product of u and v represents the distance from the origin to the point measured in the direction u. Take care with the previous sentence, it means the distance to a point in space closest to Q traveling in the direction defined by u. The following is a picture where you can modify values defining u and Q and thus explore different cases.

In [10]:
Q = vector([2,4])
u = vector([1,1])
u = (1/u.norm())*u
v = Q
pretty_print("u = ", u)
pretty_print("v = ", v)
bnd = max(v.norm(), u.norm())
d   = v.dot_product(u)
pretty_print(LatexExpr("{d \: = \: }"), d)
gu  = arrow((0,0),u,color="blue")
gv  = arrow((0,0),v,color="green")
gq  = point(tuple(Q),color="brown",size=40)
gud = line(((0,0),d*u),color="blue", linestyle="-.")
gup = point(tuple(d*u),color="red", size=40)
gub = line(((0,0),bnd*u),color="grey",alpha=0.5)
gqp = line((d*u,v),color="brown", linestyle="-.")
gos = gu + gv + gq + gud + gqp + gub + gup
gos.show(xmin=-bnd, ymin=-bnd, xmax=bnd, ymax=bnd, aspect_ratio=1)

When you understand each of the seven components in this figure then you are probably solid on the concept of the dot product as a projection operator. Lets walk through these seven parts using the python variable names for convenience.

gu ... this is the blue arrow that represents the unit length vector that in turn defines a axis onto which the point Q will be projected. Put more simply, it is the drawing of the vector u.

gv ... this is the green arrow that represents the vector from the origin out to the point Q. Here we see a first instance of our shifting use of points versus vectors.

gq ... this is the point Q drawn in brown. This is the point whose distance from the origin we seek to measure in the direction defined by the vector u.

d ... this is not explicitly drawn, but d is the signed distance from the origin to the point closest to Q in the direction u.

gud ... this is a dashed blue line showing visually the distanct traveled from the origin out to the point closest to Q in the direction u.

gup ... this is a point drawn in red signifying the point along the direction of u closest to Q

gub ... this is an extension of the vector u signifying what may be thought of as the u-axis.

gqp ... this is a dashed brown line illustrating the 'projection' of Q onto the u-axis. Note it is a line perpendicular to the u-axis and passing throught the point Q.