Code covered by the BSD License  

Highlights from
animEuler

image thumbnail
from animEuler by Dmitry Savransky
Animate sets of Euler rotations using arbitrary Euler angles and rotation order.

rot3daxes(h,as,l,ang,axSym,killLines)
function rot3daxes(h,as,l,ang,axSym,killLines)
% rot3daxes preforms a simple rotation of an axis set created by make3daxes.
% 
% rot3daxes(h,as,l,ang) rotates the surface objects with
% handles in array (as) in figure (h) by an angle (ang) about the axis
% defined by array (l).  The handles are assumed to be of surface objects
% generated by the function make3daxes and the angle is assumed to be in
% degrees.
%
% rot3daxes(...,axSym) plots the previous axis positions with linesytle
% axSym.
%
% rot3daxes(...,killLines) removes previous line objects from the figure,
% when killLines is set to true.
%
% Note: This function is intended to be called by animEuler.m
% 
% Examples:  
%     %rotate axes 45 degrees about z axis.
%     rot3daxes(h,as,[0,0,1],45,'--')

% Written by Dmitry Savransky 29 April 2009

if ~exist('axSym','var') || isempty(axSym)
    axSym = '--';
end
if ~exist('killLines','var')
    killLines = false;
end
%set figure and remove any previous line objects if requested
figure(h);

if killLines
    oldObjs = findobj(h,'Type','line');
    if ~isempty(oldObjs), delete(oldObjs); end
end

%plot orig axes
hold on
col = ['r','g','b'];
for j=1:3
    a = get(as(j),{'Xdata','Ydata','Zdata'});
    plot3(mean(a{1},2),mean(a{2},2),mean(a{3},2),[col(j),axSym],'LineWidth',2);
end

for j=1:20
    for i=1:3
        rotate(as(i),l,ang/20,[0,0,0])
    end
    pause(0.1);
end
% axis equal;
% axis([-1 1 -1 1 -1 1])
% view(45,15)
% grid on

Contact us at files@mathworks.com