Skip to content

Commit

Permalink
Merge branch 'refs/heads/far-grps'
Browse files Browse the repository at this point in the history
Rate limit · GitHub

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.

tuckermcclure committed May 14, 2016
2 parents 223e78b + 5e1af46 commit e0e2bfc
Showing 37 changed files with 640 additions and 778 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ Untitled*
*.mexw32
*.mexa64
*.mexmaci64
/generated/

# Autogenerated code folder
/codegen/
18 changes: 0 additions & 18 deletions Untitled.m

This file was deleted.

2 changes: 1 addition & 1 deletion aa2dcm.m
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
['%s: The number of input axes must match the number of ' ...
'input angles.'], mfilename);

% Pre-allocate the DCMs.
% Preallocate the DCMs.
R = zeros(3, 3, length(theta), class(theta));

% If running in regular MATLAB, vectorize.
61 changes: 0 additions & 61 deletions aa2grp.m

This file was deleted.

46 changes: 46 additions & 0 deletions aa2mrp.m
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
9 changes: 9 additions & 0 deletions aashort.m
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
96 changes: 65 additions & 31 deletions build_vectors_and_rotations.m
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
2 changes: 1 addition & 1 deletion dcm2ea.m
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
alpha = -1;
end

% Pre-allocate.
% Preallocate.
ea = zeros(3, size(R, 3), class(R));

% If symmetric...
2 changes: 1 addition & 1 deletion dcm2q.m
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
assert(size(R, 1) == 3 && size(R, 2) == 3, ...
'%s: The axes must be 3-by-n.', mfilename);

% Pre-allocate.
% Preallocate.
q = zeros(4, n, class(R));

% Split the conversion so as to divide by the largest possible number.
2 changes: 1 addition & 1 deletion ea2dcm.m
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));

2 changes: 1 addition & 1 deletion ea2q.m
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));

37 changes: 0 additions & 37 deletions grp2aa.m

This file was deleted.

64 changes: 0 additions & 64 deletions grp2dcm.m

This file was deleted.

Rate limit · GitHub

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.

0 comments on commit e0e2bfc

Please sign in to comment.