-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add faster cross function alternative
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function c = crossFast(a,b) | ||
% crossFast faster implementation of cross function | ||
% This function only works for 3xN array inputs but is much faster | ||
% compared to cross. | ||
% | ||
% Syntax: | ||
% c = crossFast( a, b ) | ||
% | ||
% Inputs: | ||
% a first vectors (3xN array) | ||
% b second vectors (3xN array) | ||
% | ||
% Outputs: | ||
% c product of inputs (3xN array) | ||
% | ||
% See also: | ||
% cross | ||
|
||
% Disclamer: | ||
% SPDX-License-Identifier: GPL-2.0-only | ||
% | ||
% Copyright (C) 2022 Yannic Beyer | ||
% Copyright (C) 2022 TU Braunschweig, Institute of Flight Guidance | ||
% ************************************************************************* | ||
|
||
% Calculate cross product | ||
c(3,:) = a(1,:).*b(2,:)-a(2,:).*b(1,:); | ||
c(1,:) = a(2,:).*b(3,:)-a(3,:).*b(2,:); | ||
c(2,:) = a(3,:).*b(1,:)-a(1,:).*b(3,:); | ||
|
||
end |