function c = cross(a,b)
%CROSS	Vector cross product.
%	C = CROSS(A,B) returns the cross product of the vectors
%	A and B.  That is, C = A x B.  A and B must be 3 element
%	vectors.
%
%	Also works if A and B are 3-by-N matrices, in which
%	case C is a 3-by-N matrix containing the cross product
%	between the corresponding columns of A and B.
%
%	See also: DOT.

%	Clay M. Thompson
%	Copyright (c) 1984-94 by The MathWorks, Inc.

if isstr(a) & isstr(b),
   c = ['norm(' a ') * norm(' b ') * sin(angle(' a ',' b '))'];
else
  rowvec = 0;
  if size(a,1)==1, a = a(:); rowvec = 1; end
  if size(b,1)==1, b = b(:); rowvec = 1; end
  if (size(a,1)~=3) | (size(b,1)~=3),
    error('A and B must be 3-vectors or 3-by-N matrices.');
  end
  c = [a(2,:).*b(3,:)-a(3,:).*b(2,:)
       a(3,:).*b(1,:)-a(1,:).*b(3,:)
       a(1,:).*b(2,:)-a(2,:).*b(1,:)];
  if rowvec, c = c.'; end
end

