CROSS3 3D cross parallel cross product C = CROSS3(A,B) calculates the cross product between rows of matrices A and B, both of which must be Nx3. C is also Nx3 such that C(i,:) = cross(A(i,:),B(i,:)) but it is calculated faster.
0001 function c = cross3(a,b) 0002 %CROSS3 3D cross parallel cross product 0003 % C = CROSS3(A,B) calculates the cross product between rows of matrices A 0004 % and B, both of which must be Nx3. C is also Nx3 such that 0005 % C(i,:) = cross(A(i,:),B(i,:)) 0006 % but it is calculated faster. 0007 0008 % (C) 2013 Bartlomiej Grychtol. License: GPL version 2 or 3. 0009 % $Id: cross3.m 4260 2013-06-24 15:17:15Z aadler $ 0010 0011 c = [a(:,2).*b(:,3)-a(:,3).*b(:,2), ... 0012 a(:,3).*b(:,1)-a(:,1).*b(:,3), ... 0013 a(:,1).*b(:,2)-a(:,2).*b(:,1)];