Example 6.4.3

This notebook shows the geometric interpretation of vector projection for 3-dimensional vectors given in example 6.4.3.  Given vectors (OverVector[v]) (in blue) and (OverVector[w]) (in green),  the projection of (OverVector[w]) onto (OverVector[v]), (Subscript[proj, (OverVector[v])])((OverVector[w])), is given in red. The vectors (OverVector[w]) and (OverVector[v]) are entered in the corresponding input fields.  Because the projection takes place in three dimensions perspective may make it hard to see what it going on, so you are able to rotate the picture freely and the space the projection would take place through (i.e. where (OverVector[w]) would pass through as it is projected on to (OverVector[v])) is slightly shaded to emphasize the projection.

DisplayProjectedVector3D[w_,v_]:=Block[{graphics, proj, perpendicular,ticks,max,k},
proj=w.v/v.v v;
perpendicular=w-proj;
max=Ceiling[Max[ Norm[w], Norm[v]]];
ticks=Table[k, {k,-Ceiling[max], Ceiling[max],Ceiling[max/4.]}];
graphics=Graphics3D[{Thick,Blue, Arrow[{{0,0,0},v}], Green,Arrow[ {{0,0,0}, w}], Red,Arrow[ {{0,0,0},proj}], Black,Text[ "w", w+{.05,.05,.05}max],Text["v", v+{.05,-.2,.05}max], Red,Opacity[.1],Polygon[{{0,0,0}, proj, w}]}];
Return[ Column[ {Show[graphics, Ticks->{ticks,ticks,ticks}, AspectRatio->Automatic, Axes->True, PlotRange->{{-max,max},{-max,max},{-max,max}}, ImageSize->300,AxesLabel->{"x","y","z"}, AxesEdge->{{-1,-1},{-1,-1},{-1,-1}},PlotLabel-> "Projection of w onto v is in red"],
Row[ {"The vector projection of the vector w ", w, " in green onto the vector v ",v," in blue is the red vector ", proj}]}]]
]

Manipulate[DisplayProjectedVector3D[w,v],{{w,{5,0,0}, "Project the green vector w "}, InputField},{{v,{4,4,4},"Onto the blue vector v "},InputField}, SaveDefinitions-> True]