Tuesday, March 09, 2010

Geometry in 3D: projection

A vector a projected onto another vector b effectively gives a vector with same orientation as b and with magnitude norm(a).*cos(span(a,b));


define
unitize = @(a)(a./norm(a));
which gives the unit vector along a;

The projection can be equivalently written in the original coordinate frame as
projection(a,b) == dot(a,b)./norm(b).*unitize(b) == dot(a,b).*b./(norm(b)^2);
Recall that
norm(b)^2 == torow(b)*tocol(b);
dot(a,b) == torow(a)*tocol(b);
suppose a, b are 1 x 3 row vectors

We have
projection(a,b) == (a*b.').*b./(b*b.') == a*(b.'*b)./(b*b.') == a*pm;
pm == (b.'*b)./(b*b.');
pm is called the projection matrix of b;

No comments: