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:
Post a Comment