-
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.
Whoa there!
You have triggered an abuse detection mechanism.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
Showing
37 changed files
with
640 additions
and
778 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ Untitled* | |
*.mexw32 | ||
*.mexa64 | ||
*.mexmaci64 | ||
/generated/ | ||
|
||
# Autogenerated code folder | ||
/codegen/ | ||
|
This file was deleted.
Oops, something went wrong.
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
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,46 @@ | ||
function p = aa2mrp(r, theta, f) | ||
|
||
% aa2mrp | ||
|
||
% Copyright 2016 An Uncommon Lab | ||
|
||
%#codegen | ||
|
||
% Set defaults so that for small angles, the scaled MRPs approach the | ||
% rotation vector. | ||
if nargin < 3 || isempty(f), f = 1; end; | ||
|
||
% Check dimensions. | ||
assert(nargin >= 2, ... | ||
'%s: At least two inputs are required.', mfilename); | ||
assert(size(r, 1) == 3, ... | ||
'%s: The axes must be 3-by-n.', mfilename); | ||
assert(size(r, 2) == size(theta, 2), ... | ||
['%s: The number of input axes must match the number of ' ... | ||
'input angles.'], mfilename); | ||
assert(all(size(f) == 1), ... | ||
'%s: The scaling factor must be a scalar.'); | ||
|
||
% If running in regular MATLAB, vectorize. | ||
if isempty(coder.target) | ||
|
||
p = bsxfun(@times, tan(0.25 * theta), r); | ||
if f ~= 1 | ||
p = f * p; | ||
end | ||
|
||
% Otherwise, write the loops. | ||
else | ||
|
||
n = size(r, 2); | ||
p = zeros(3, n, class(theta)); | ||
for k = 1:n | ||
p(:,k) = tan(0.25 * theta(k)) * r(:,k); | ||
end | ||
if f ~= 1 | ||
p = f * p; | ||
end | ||
|
||
end | ||
|
||
end % aa2mrp |
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,9 @@ | ||
function [theta, r] = aashort(theta, r) | ||
% TODO: If keeping, vectorize. | ||
theta = mod(theta, 2*pi); | ||
ind = theta >= pi; | ||
theta(ind) = 2*pi - theta(ind); | ||
if nargout >= 2 | ||
r(:,ind) = -r(:,ind); | ||
end | ||
end |
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 |
---|---|---|
@@ -1,33 +1,67 @@ | ||
% Generic values | ||
r = coder.typeof(0, [3 1], [0 1]); | ||
theta = coder.typeof(0, [1 1], [0 1]); | ||
R = coder.typeof(0, [3 3 1], [0 0 1]); | ||
q = coder.typeof(0, [4 1], [0 1]); | ||
p = coder.typeof(0, [3 1], [0 1]); | ||
ea = coder.typeof(0, [3 1], [0 1]); | ||
seq = coder.typeof(uint8(1), [1 3]); | ||
a = coder.typeof(1); | ||
f = coder.typeof(4); | ||
function built = build_vectors_and_rotations(requested) | ||
|
||
% Things to build: | ||
build = {'aa2dcm', {r, theta}; ... | ||
'aa2grp', {r, theta, a, f}; ... | ||
'aa2q', {r, theta}; ... | ||
'dcm2aa', {R}; ... | ||
'dcm2ea', {R, seq}; ... | ||
'dcm2q', {R}; ... | ||
'ea2dcm', {ea, seq}; ... | ||
'ea2q', {ea, seq}; ... | ||
'grp2aa', {p, a, f}; ... | ||
'grp2dcm', {p, a, f}; ... | ||
'grp2q', {p, a, f}; ... | ||
'q2aa', {q}; ... | ||
'q2dcm', {q}; ... | ||
'q2ea', {q, seq}; ... | ||
'q2grp', {q, a, f}}; | ||
% Generic values | ||
n = inf; | ||
r = coder.typeof(0, [3 n], [0 1]); | ||
theta = coder.typeof(0, [1 n], [0 1]); | ||
R = coder.typeof(0, [3 3 n], [0 0 1]); | ||
q = coder.typeof(0, [4 n], [0 1]); | ||
p = coder.typeof(0, [3 n], [0 1]); | ||
ea = coder.typeof(0, [3 n], [0 1]); | ||
t = coder.typeof(0, [1, inf], [0 1]); | ||
qi = coder.typeof(0, [4, inf], [0 1]); | ||
seq = coder.typeof(uint8(1), [1 3]); | ||
f = coder.typeof(1); | ||
|
||
% Build everything. | ||
for k = 1:size(build, 1) | ||
fprintf('Building %s...\n', build{k, 1}); | ||
codegen('-config:mex', build{k, 1}, '-args', build{k, 2}); | ||
end | ||
% Things to build: | ||
build = {'aa2dcm', {r, theta}; ... | ||
'aa2mrp', {r, theta, f}; ... | ||
'aa2q', {r, theta}; ... | ||
'dcm2aa', {R}; ... | ||
'dcm2ea', {R, seq}; ... | ||
'dcm2q', {R}; ... | ||
'ea2dcm', {ea, seq}; ... | ||
'ea2q', {ea, seq}; ... | ||
'mrp2aa', {p, f}; ... | ||
'mrp2dcm', {p, f}; ... | ||
'mrp2q', {p, f}; ... | ||
'q2aa', {q}; ... | ||
'q2dcm', {q}; ... | ||
'q2ea', {q, seq}; ... | ||
'q2mrp', {q, f}; ... | ||
'mrpalt', {p, f}; ... | ||
'mrpcomp', {p, p, f}; ... | ||
'mrpdiff', {p, p, f}; ... | ||
'mrperr', {p, p, f}; ... | ||
'qcomp', {q, q}; ... | ||
'qdiff', {q, q}; ... | ||
'qerr', {q, q}; ... | ||
'qinv', {q}; ... | ||
'qpos', {q}; ... | ||
'qrot', {q, r}; ... | ||
'rae2xyz', {r}; ... | ||
'xyz2rae', {r}}; | ||
... 'qinterp', {t, qi, t}; ... | ||
|
||
% If only a subset is requested, find out which. | ||
if nargin >= 1 | ||
indices = false(length(build), 1); | ||
for k = 1:length(requested) | ||
indices = indices | strcmp(build(:,1), requested{k}); | ||
end | ||
build = build(indices, :); | ||
end | ||
|
||
% Build everything. | ||
tic(); | ||
for k = 1:size(build, 1) | ||
fprintf('Building %s...\n', build{k, 1}); | ||
codegen('-config:mex', build{k, 1}, ... | ||
'-args', build{k, 2}); | ||
end | ||
toc(); | ||
|
||
% Return the names of the built functions. | ||
built = build(:,1); | ||
|
||
end % build_vectors_and_rotations |
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
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
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
alpha = -1; | ||
end | ||
|
||
% Pre-allocate. | ||
% Preallocate. | ||
n = size(ea, 2); | ||
R = zeros(3, 3, n, class(ea)); | ||
|
||
|
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
alpha = -1; | ||
end | ||
|
||
% Pre-allocate. | ||
% Preallocate. | ||
n = size(ea, 2); | ||
q = zeros(4, n, class(ea)); | ||
|
||
|
Whoa there!
You have triggered an abuse detection mechanism.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.