First we define some utility functions;
torow = @(x)(x(:).');tocol = @(x)(x(:));
norm (L2, Euclidean) of a vector is a scalar defined as
norm(a) == sqrt(sum(a.^2)) == sqrt(torow(a)*tocol(a)) == sqrt(dot(a,a));
dot(a,b) == sum(a.*b) == torow(a)*tocol(b);
cross product of two vectors is a vector orthogonal to both, following the right hand rule:
cross(a,b) == ([a(2)*b(3)-a(3)*b(2),...a(3)*b(1)-a(1)*b(3),...a(1)*b(2)-a(2)*b(1)]); % each row corresponds to an axis;
Right hand rule:

(Image from Wikipedia)
Some very commonly used properties:
dot(a,b) == norm(a).*norm(b).*cos(span(a,b));
span(a,b) == acos(dot(a,b)./norm(a)./norm(b));
where span() is the angle spanned between two vectors;
norm(cross(a,b)) == norm(a).*norm(b).*sin(span(a,b));
span(a,b) == atan2(norm(cross(a,b)),dot(a,b));
This formula of span(a,b) is more robust than the acos version at near pi/2; the convention of such angle is measured by the shortest great circle path between two vectors;
No comments:
Post a Comment