e = deg2rad([-30 20 10; 60 10 5]);
q = quaternion(e, 'euler', 'ZYX', 'frame');
qs = slerp(q(1), q(2), linspace(0,1,100)');
tp = theaterPlot('XLimit',[-2 2],'YLimit',[-2 2],'ZLimit',[-2 2]);
op = orientationPlotter(tp,'DisplayName','body axis');
for i=1:numel(qs)
plotOrientation(op, qs(i));
drawnow;
end
sc = trackingScenario;
cube = platform(sc);
cube.Dimensions = struct('Length',5,'Width',5,'Height',5,'OriginOffset',[0 0 0]);
tp = theaterPlot('XLimit',[-10 10],'YLimit',[-10 10],'ZLimit',[-10 10]);
op = orientationPlotter(tp,'DisplayName','body axis');
L = cube.Dimensions.Length;
W = cube.Dimensions.Width;
H = cube.Dimensions.Height;
offset = cube.Dimensions.OriginOffset;
f = [ 1 1 1; 1 -1 1; 1 -1 -1; 1 1 -1] .* [L W H]/2 - offset;
r = [ 1 1 1; 1 1 -1;-1 1 -1;-1 1 1] .* [L W H]/2 - offset;
d = [ 1 1 1;-1 1 1;-1 -1 1; 1 -1 1] .* [L W H]/2 - offset;
b = [-1 1 1;-1 1 -1;-1 -1 -1;-1 -1 1] .* [L W H]/2 - offset;
l = [-1 -1 1;-1 -1 -1; 1 -1 -1; 1 -1 1] .* [L W H]/2 - offset;
u = [ 1 1 -1; 1 -1 -1;-1 -1 -1;-1 1 -1] .* [L W H]/2 - offset;
hTransform = hgtransform(tp.Parent);
patch(hTransform, f(:,1), f(:,2), f(:,3), 'red', 'FaceAlpha',.6);
patch(hTransform, l(:,1), l(:,2), l(:,3), 'yellow', 'FaceAlpha',.6);
patch(hTransform, u(:,1), u(:,2), u(:,3), 'cyan', 'FaceAlpha',.6);
patch(hTransform, b(:,1), b(:,2), b(:,3), 'magenta','FaceAlpha',.6);
patch(hTransform, r(:,1), r(:,2), r(:,3), 'green', 'FaceAlpha',.6);
patch(hTransform, d(:,1), d(:,2), d(:,3), 'blue', 'FaceAlpha',.6);
e = deg2rad([-30 20 10; 60 10 5]);
q = quaternion(e, 'euler', 'ZYX', 'frame');
qs = slerp(q(1), q(2), linspace(0,1,100)');
for i=1:numel(qs)
position = [0 0 0];
plotOrientation(op, qs(i), position);
M = eye(4);
M(1:3,1:3) = rotmat(qs(i),'point');
hTransform.Matrix = makehgtform('translate',position)*M;
drawnow;
end